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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BenediktBertsch
Copy link

@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.

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.

1 participant