Search code examples
c#asp.netasp.net-corethumbnailsvideo-processing

Generate/Fetch thumbnail from video files for official use without using FFMPEG in c# for commercial purpose


I'm creating the file manager in .NET core using c# and devexpress control filemanager. for this I want to generate thumbnails for video files but it is for commercial purpose so I cant use FFMPEG for the same. Any help will be appreciated.

I tried MediaToolkit but it didn't worked in .Net Core. I have checked the solutions like

  1. NReco
  2. MediaToolkit.NetCore
  3. ShellFile
  4. Xabe.FFmpeg

But many from this above solutions requires FFMPEG.exe which I cant use commercial purpose.


Solution

  • ShellFile is available, but it does not seem to support .net 5 and .net6 versions. If you use version 3.1, you can try this.

    You need to install two Nuget packages: Microsoft-WindowsAPICodePack-Shell and System.Drawing.Common. Here you need to pay attention to the choice of Microsoft-WindowsAPICodePack-Shell:

    enter image description here

    Test Code:

    public IActionResult Index()
    {
        ShellFile shellFile = ShellFile.FromFilePath("file path\\filename");
        Bitmap bitmap = shellFile.Thumbnail.Bitmap;
        bitmap.Save("File output path\\filename", System.Drawing.Imaging.ImageFormat.Jpeg);
        return View();
    }
    

    For example, I output it to the Models folder:

    enter image description here

    For more details, you can refer to this link.