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

Generation of video thumbnail makes ffmpeg spawn 6mb-sized processes infinitely

Open aignatovich opened this issue 4 years ago • 1 comments

I am following a posted example to generate poster frame for an mp4 video of 50 megabytes in size (without using direct reference to ffmpeg executable). I am using ffmpeg 4.3.1. and this is the only installed version.

var inputFile = new MediaFile (@"C:\Path\To_Video.flv");
var outputFile = new MediaFile (@"C:\Path\To_Save_Image.jpg");

var ffmpeg = new Engine();
// Saves the frame located on the 15th second of the video.
var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(15) };
await ffmpeg.GetThumbnailAsync(inputFile, outputFile, options);

The above code results into infinite loop somewhere in ffmpeg on the last line. At the same time command below works perfectly, so ffmpeg should not be an issue.

ffmpeg -ss 00:00:05.01 -i random.mp4 -frames:v 1 myimage.jpg

By any chance does anyone have an idea what I might be doing wrong? Is this a library-related issue or an issue related to ffmpeg executable?

aignatovich avatar Jan 27 '21 09:01 aignatovich

@aignatovich how about instead of using await, use Task.Run to run your code in a async thread and once you get your thumbnail, try to stop/dispose/null the ffmpeg var.

shubhank008 avatar Apr 26 '21 18:04 shubhank008