Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add av1 support for smaller snapshots and videos #523

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

BenediktBertsch
Copy link
Contributor

@BenediktBertsch BenediktBertsch commented Jun 8, 2024

Found out that the lib didnt support the AV1 format therefore I added it for myself.

With this you can create smaller images like this:

var source = FFProbe.Analyse(file.FullName);
var streamIndex = source.PrimaryVideoStream?.Index
                ?? source.VideoStreams.FirstOrDefault()?.Index
                ?? 0;
var args = FFMpegArguments
            .FromFileInput(file.FullName, false, options => options
            .Seek(TimeSpan.FromSeconds(source.Duration.TotalSeconds / 3)));
var opts = new Action<FFMpegArgumentOptions>(options => options.SelectStream((int)streamIndex, 0)
                                            .WithVideoCodec(VideoCodec.LibaomAv1)
                                            .WithFrameOutputCount(1)
                                            .Resize(null));
args.OutputToFile(name, false, opts).ProcessSynchronously();

This takes way longer but the size difference is huge for example: 1811KB in .png to 98KB in .avif

If there is anything missing to do like writing tests etc. just mention it. I havent seen any tests for the VideoCodec.Png therefore I didnt implement any tests yet.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.00%. Comparing base (f8407bc) to head (e8ef580).
Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
FFMpegCore/FFMpeg/Enums/Enums.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #523      +/-   ##
==========================================
- Coverage   74.31%   71.00%   -3.31%     
==========================================
  Files         113      115       +2     
  Lines        2854     2925      +71     
  Branches        0      277     +277     
==========================================
- Hits         2121     2077      -44     
- Misses        733      740       +7     
- Partials        0      108     +108     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rosenbjerg rosenbjerg merged commit 5bddf38 into rosenbjerg:main Dec 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants