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}]");
}
}
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();
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