We have been generating thumbnails from image and we all know how easy is this in todays world with some awesome libraries available to us .
But when coming to generate a thumbnail from a video in C# we are left with very limited option.
But to our rescue is a beautiful library Xabe.FFmpeg by tomaszzmuda
This Library does more of what you can expect.
To understand more. This Library is a Cross-platform wrapper for FFmpeg.
FFmpeg – A complete, cross-platform solution to record, convert and stream audio and video. To read more about it click here
Please Note: ffmpeg is required to be present in your machine to use this package.
We can Download it directly from the website
You can use a beautiful Download Package and download it in runtime when required.
using Xabe.FFmpeg.Downloader; await FFmpegDownloader.GetLatestVersion(FFmpegVersion.Official, @"c:\ffmpeg");
This will download the two files required to work with the above package. to the path you mentioned. In out case its c:\ffmpeg
Now you can just start using the library.
Set the Path for the package to find the executeables.
using Xabe.FFmpeg; FFmpeg.SetExecutablesPath(@"c:\ffmpeg");
Now you can provide the video for with the thumbnail is to be generated.
using Xabe.FFmpeg; var conversion = await FFmpeg.Conversions.FromSnippet.Snapshot(originPath, outputPath,TimeSpan.FromSeconds(0)); IConversionResult result = await conversion.Start();
And you are Done. You can now find the Thumbnail in the outputPath you mentioned. In case you want the image generated you can read as stream from the above path.