cmxl / FFmpeg.NET

.NET wrapper for common ffmpeg tasks
MIT License
611 stars 99 forks source link

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

Open aignatovich opened 3 years ago

aignatovich commented 3 years ago

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?

shubhank008 commented 3 years ago

@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.