Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.DllNotFoundException: Cannot load FFmpeg libraries #136

Open
sparrowhawk26 opened this issue Jan 7, 2024 · 2 comments
Open

System.DllNotFoundException: Cannot load FFmpeg libraries #136

sparrowhawk26 opened this issue Jan 7, 2024 · 2 comments

Comments

@sparrowhawk26
Copy link

sparrowhawk26 commented Jan 7, 2024

Hi,

I am using FFMedialTookKit 4.5.1 with .net core 6.0 on linux ubuntu official asp.net microsoft image mcr.microsoft.com/dotnet/aspnet:6.0-focal

I got and exception System.DllNotFoundException: Cannot load FFmpeg libraries
no matter which path i set in FFmpegLoader.FFmpegPath = Configuration.GetValue<string>("ffmpeg");

when i attach a bash to my container i can check that ffmpeg is correctly installed at /usr/bin
i tried all paths /usr/bin /usr/share/ffmpeg /usr/lib /usr/lib/x86_64-linux-gnu

i also run

FFmpeg.Loader.FFmpegLoader.SearchSystem();
FFmpeg.Loader.FFmpegLoader.SearchApplication(); 

i got the same error (the found path is /usr/lib/x86_64-linux-gnu)

the full stacktrace :

System.Exception: Failed to open the media stream
       ---> System.DllNotFoundException: Cannot load FFmpeg libraries from /usr/lib/x86_64-linux-gnu directory.
      Required FFmpeg version: 6.x (shared build)
      Make sure the "Build"Prefer 32-bit" option in the project settings is turned off.
      For more information please see https://github.com/radek-k/FFMediaToolkit#setup
       ---> System.NotSupportedException: Specified method is not supported.
         at FFmpeg.AutoGen.DynamicallyLoadedBindings.<>c.<Initialize>b__2_1162()
         at FFmpeg.AutoGen.DynamicallyLoadedBindings.<>c.<Initialize>b__2_452()
         at FFmpeg.AutoGen.ffmpeg.av_version_info()
         at FFMediaToolkit.FFmpegLoader.LoadFFmpeg()
         --- End of inner exception stack trace ---
         at FFMediaToolkit.FFmpegLoader.HandleLibraryLoadError(Exception exception)
         at FFMediaToolkit.FFmpegLoader.LoadFFmpeg()
         at FFMediaToolkit.Decoding.Internal.InputContainer.MakeContext(String url, MediaOptions options, AVFormatContextDelegate contextDelegate)
         at FFMediaToolkit.Decoding.Internal.InputContainer.MakeContainer(Stream input, MediaOptions options)
         at FFMediaToolkit.Decoding.Internal.InputContainer.LoadStream(Stream stream, MediaOptions options)
         at FFMediaToolkit.Decoding.MediaFile.Open(Stream stream, MediaOptions options)
         --- End of inner exception stack trace ---
         at FFMediaToolkit.Decoding.MediaFile.Open(Stream stream, MediaOptions options)
         at FFMediaToolkit.Decoding.MediaFile.Open(Stream stream)

I don't know what to do

Thanks for your help

@curtmantle
Copy link

Hello,

I ran into the exact same issue and could not get it to work with the latest version of FFmpeg. The solution was to get the shared libraries of an older version of FFmpeg and place this in the /usr/lib/x86_64-linux-gnu folder.

The one I got was from here:

https://github.com/BtbN/FFmpeg-Builds/releases/tag/autobuild-2023-07-31-12-50

And the specific download was: ffmpeg-n6.0-32-gd4a7a6e7fa-linux64-gpl-shared-6.0.tar.xz

This worked for me so it seems that the nuget package is not compatible with the latest version.

Hope this helps.

@pachojavier23
Copy link

pachojavier23 commented May 31, 2024

Hello,

Currently I have the same issue, and even applying the suggestion by @curtmantle , it doesn't seem to work.

I've put all files and folders on ffmpeg-n6.0-32-gd4a7a6e7fa-linux64-gpl-shared-6.0.tar inside /usr/lib/x86_64-linux-gnu/ffmpeg

I'm registering the ffmpeg folder like this:

private static void LoadFFMpeg()
 {
     string path = Path.Combine("/", "usr", "lib", "x86_64-linux-gnu", "ffmpeg", "bin");

         FFmpegLoader.FFmpegPath = path;
 }

but I'm getting the following error when FFMediaToolkit registers the binaries:

Specified method is not supported. --    at FFmpeg.AutoGen.DynamicallyLoadedBindings.<>c.<Initialize>b__2_1162()
   at FFmpeg.AutoGen.ffmpeg.av_version_info()
   at FFMediaToolkit.FFmpegLoader.LoadFFmpeg()

I also print the ffmpeg version loaded by the toolkit and I'm getting an n/a.

This project is made in .netcore 8 and is deployed in an isolated azure function on linux64, which uses Debian

Locally on windows it works fine with the dll files obviously changing the location of the binaries.

I appreciate your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants