Xabe.FFmpeg icon indicating copy to clipboard operation
Xabe.FFmpeg copied to clipboard

Unable to get frames from a video

Open MattiaudaNicolasCN opened this issue 3 years ago • 0 comments

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

MattiaudaNicolasCN avatar Dec 27 '21 15:12 MattiaudaNicolasCN