Xabe.FFmpeg
Xabe.FFmpeg copied to clipboard
Unable to get frames from a video
Hi!
I have a problem because I should be able to save every frame of a video / stream but with the .ExtractNthFrame()
method it seems not to work.
This is my code:
static async Task StartStream()
{
Func<String, String> outputFileNameBuilder = (number) => { return "frame" + number + ".png"; };
String url = "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
IMediaInfo info = await FFmpeg.GetMediaInfo(url);
IVideoStream videoStream = info.VideoStreams.FirstOrDefault()?.SetCodec(VideoCodec.mjpeg);
String output =Path.Combine(@"C:\", "Test");
IConversionResult conversionResult = await FFmpeg.Conversions.New()
.AddStream(videoStream)
.AddParameter("-rtsp_transport tcp")
.SetInputTime(TimeSpan.FromSeconds(30))
.ExtractNthFrame(1,outputFileNameBuilder)
.SetOutput(output)
.Start();
}
When I run this code no png images are saved in the C:\Test
directory. Where I am wrong?
The Xabe.FFmpeg version that I am using is 5.0.2 from Nuget