tomaszzmuda / Xabe.FFmpeg

.NET Standard wrapper for FFmpeg. It allows to process media without know how FFmpeg works, and can be used to pass customized arguments to FFmpeg from dotnet core application.

Home Page:https://xabe.net/product/xabe_ffmpeg/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sample code does not work.

HubKing opened this issue · comments

https://ffmpeg.xabe.net/tutorial.html

private static async Task RunConversion(Queue filesToConvert)
{
    while(filesToConvert.TryDequeue(out FileInfo fileToConvert))
    {
        //Save file to the same location with changed extension
        string outputFileName = Path.ChangeExtension(fileToConvert.FullName, ".mp4");
        await Conversion.ToMp4(fileToConvert.FullName, outputFileName).Start();
        await Console.Out.WriteLineAsync($"Finished converion file [{fileToConvert.Name}]");
    }
}

image

https://ffmpeg.xabe.net/docs.html

string output = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".mp4");
var snippet = FFmpeg.Conversions.FromSnippet.Convert(Resources.MkvWithAudio, output);
IConversionResult result = await snippet.Start();

image

The first one seems to have been already reported by another user months ago.

The second one could be fixed with an "await".

var snippet = await FFmpeg.Conversions.FromSnippet.Convert....

Okay I might have solution to your problem. Mine is used for converting video into images. The documentation is for dotnet5. so in dotnet6 use conversions method instead of conversion method.
//Turn Video into images Func<string, string> outputFileNameBuilder = (number) => { return convertedVideoDir + "\\fileNameNo" + number + ".png"; };
IMediaInfo info = await FFmpeg.GetMediaInfo(testFilePath).ConfigureAwait(false);
IVideoStream videoStream = info.VideoStreams.First()?.SetCodec(VideoCodec.png);
IConversionResult conversionResult = await FFmpeg.Conversions.New().AddStream(videoStream).ExtractEveryNthFrame(2, outputFileNameBuilder).SetOutput(convertedVideoDir).Start();

@HubKing
I've updated both examples in the documentation. If you see more issues feel free to tell me