Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Cannot found the default FFmpeg directory bei FFMediaTookit

 

error message

Cannot found the default FFmpeg directory.

On Windows you have to set "FFmpegLoader.FFmpegPath" with full path to the directory containing FFmpeg shared build ".dll" files

For more informations please see https://github.com/radek-k/FFMediaToolkit#setup

 

When creating thumbnail images from a video

 

Integration of FFMediaToolkit via Nuget Packages

FFMediaToolkit

Cross-platform audio/video processing library based on FFmpeg native libraries. Supports audio/video frames extraction (fast access to any frame by timestamp), reading file metadata and encoding media files from bitmap images and audio data.

Problem Code

using FFMediaToolkit;

using FFMediaToolkit.Decoding;

using FFMediaToolkit.Graphics;

//using SixLabors.ImageSharp;

//using SixLabors.ImageSharp.PixelFormats;

 

   public static void FFMediaToolKit_Code()

    {

try

        {

            FFmpegLoader.FFmpegPath = Path.Combine(executionContext.FunctionDirectory, "ffmpeg", "x86_64");

        }

        catch

        {

            //Ignore exceptions while loading the assemblies.

        }

        using var file = MediaFile.Open(myBlob);

        file.Video.TryGetNextFrame(out var imageData);

        imageData.ToBitmap().SaveAsJpeg(outputBlob);

    }

    public static Image<Bgr24> ToBitmap(this ImageData imageData)

    {

        return Image.LoadPixelData<Bgr24>(imageData.Data, imageData.ImageSize.Width, imageData.ImageSize.Height);

    }

 

 

 

solution:

It is better if you do not use FFMediaToolkit, delete it and instead insert the much simpler code to call FFMpeg directly

It is easier if you call and execute FFMpeg.exe directly as a c# process.

Using System.Diagnostics;   //ProcessStartInfo

 

public static class Video_Methods

{

    public static void Video_create_Thumbnail(string Video_Path, string output_Image_Path, int new_Width, string sPath_FFMpeg)

    {

        //---------------< Video_create_Thumbnail() >---------------

        string sPath_FFMpegDir = @"D:\FFMpeg\";

 

        string sInputFile = @"D:\xx\Video_2618_0.mp4";

        string sOutputFile = @"D:\xxx\Images\thumb_2618_0.jpg";

        var startInfo = new ProcessStartInfo

        {

            FileName = sPath_FFMpegDir + $"ffmpeg.exe",

            Arguments = $"-i " + sInputFile + " -an -vf scale=200x112 " + sOutputFile + " -ss 00:00:00 -vframes 1",

            CreateNoWindow=true,

            UseShellExecute=false,

            WorkingDirectory=sPath_FFMpegDir

        };

 

        using (var process=new Process { StartInfo=startInfo})

        {

            process.Start();

            process.WaitForExit();

 

        }

 

        //---------------</ Video_create_Thumbnail() >---------------

    }

}

 

 

 

 

Bei beiden Vorgängen muss man FFMpeg downloaden und als dll und exe im Asp Core .Net5 oder MVC speichern:

Ich habe die FFMpeg Dateien in den Ausgabe /bin Pfad gelegt neben Debug und Public

 

 

Also affects the error message

 

The specified FFmpeg directory does not exist!

Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de