Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

✅ Cannot found the default FFmpeg directory bei FFMediaTookit

28.07.2021 (👁13216)


Fehlermeldung

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

 

Beim Erstellen von Thumbnail Images aus einem Video

Einbindung FFMediaToolkit über 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);

    }

Lösung:

Besser ist es, wenn man auf die Verwendung von FFMediaToolkit verzichtet, diese löscht und statt dessen den viel einfacheren Code einfügt zum direkten Aufruf von FFMpeg

Einfacher ist es, wenn man FFMpeg.exe direkt als c# Prozess aufruft und ausführt.

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!