-
Notifications
You must be signed in to change notification settings - Fork 245
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
Could not load type 'FFmpeg.AutoGen.Native.LibraryLoader' from assembly 'FFmpeg.AutoGen #679
Comments
What if you test the loader directly and go from there?
|
Hello Hans
Thanks for responding! For what its worth, I am not familiar with the actual FFME source code. Rather, I am just testing the FFME package with a minimalist WPF program (see below) to see if I can even get it to play a single video, as I am frustrated by the limits of the Windows-supplied MediaElement.
I have a feeling that it could be a version issue with my ffmpeg package, where I am perhaps downloading the wrong or version expected by FFME. Unfortunately, the FFME web site points to an ffmpeg package with a stale link. I experimented with various ffmpeg versions, with no luck. This includes what FFME seems to suggest is the correct ffmpeg package, which I found on the internet archive: https://archive.org/details/ffmpeg-4.2.1-win64-shared (I also tried the win32 package that is there) but no luck with either of them (this includes testing with prefer 32 bit set to the correct value depending on the package).
As for your suggestion, I am not quite sure what the role of the FFmpget.Loader is in your example below (I am just using the FFME package as is, so am not familiar with the way it tries to find ffmpeg ddls), but…
* I included the FFmpeg.Loader package from Nuget
* I then had varying degrees of success in terms of the Loader returning a result, depending upon which FFMPEG package I had downloaded. For most packages, it returns a dll not found. I was able to get the loader to return a string from one ffmpeg bin package (e.g., 6.0-full_build-www.gyan.dev) , but not for the 4.2.1 package above.
If you are willing, I can zip up my entire solution and send it to you. It really is a minimalist program (see below): aside from adding FFME via nuget and adding the component to xaml (and your FFmegLoader suggestion), this is all I am doing. Any help would be appreciated to just get things to run!
using System;
using System.Diagnostics;
using System.IO;
using System.Windows;
using FFmpeg.Loader;
namespace FFMETest
{
public partial class MainWindow : Window
{
private static readonly string RootPath = @"D:\FFMETest"; // everything is stored in this folder
private static readonly string FFMPEGpath = Path.Combine(RootPath, "ffmpegbin"); // folder with ffmpeg binaries/dlls
private static readonly string VideoPath = Path.Combine(RootPath, "testVideos"); // folder with test videos
private static readonly string SampleVideoPath = Path.Combine(VideoPath, "vid2.mp4"); // the test video
public MainWindow()
{
InitializeComponent();
try
{
Debug.Print(FFmpegLoader.SearchPaths(FFMPEGpath).Load());
}
catch (Exception e)
{
// Exception is raised here for most (but not all) ffmpeg binaries tried
Debug.Print($"FFmpegLoader could not load {FFMPEGpath} : {e.Message}");
return;
}
Unosquare.FFME.Library.FFmpegDirectory = FFMPEGpath;
}
private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
if (File.Exists(SampleVideoPath))
{
// One ffmpeg package actually passed the FFmpgetLoader test above , but trying to open the video produced this error message:
// - Could not load type 'FFmpeg.AutoGen.Native.LibraryLoader' from assembly 'FFmpeg.AutoGen, Version=6.0.0.2, …
await Media.Open(new Uri(SampleVideoPath));
}
else
{
MessageBox.Show($"Video not found: {SampleVideoPath}");
}
}
}
}
From: Hans Håkansson ***@***.***>
Sent: November 24, 2024 4:19 AM
To: unosquare/ffmediaelement ***@***.***>
Cc: Saul Greenberg ***@***.***>; Author ***@***.***>
Subject: Re: [unosquare/ffmediaelement] Could not load type 'FFmpeg.AutoGen.Native.LibraryLoader' from assembly 'FFmpeg.AutoGen (Issue #679)
[△EXTERNAL]
What if you test the loader directly and go from there?
Other things to test.
Is ffmpeg.exe working from the command line?
Try to set the build to x64
using FFmpeg.Loader;
FFmpegLoader.SearchPaths(@"C:\ffmpeg-n6.0-win64-lgpl-shared-6.0\bin").Load();
—
Reply to this email directly, view it on GitHub<#679 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADZRUMAF2ARSHS22K2XNDDT2CGYZRAVCNFSM6AAAAABSLFOBIKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJVHE2DOMZQGY>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
I think I understand the problem. The author has not published any new NuGet packages since 2021, but the source code has been updated. If you try to use the published NuGet package, it will be outdated. To resolve this, you need to clone the repository, build the solution, and obtain the ffme.win.dll assembly. Then, place it in your application's directory and reference it. You should target .NET rather than .NET Framework. If you clone the repository, there is a working sample application included that you can study: The FFmpeg binaries can be found here: That page will link to a few build repositories, such as: Note: FFmpeg version 7 is not supported. |
First, I really appreciate you help, even if in the end the answer may be that FFME is not compatible with what I am trying to do.
So. I was able to get the build and sample to work (i.e., the code on FFME github), but still couldn’t get my sample to work. Simply adding the references to ffme.win (without even using it in code) generates a build error
“Unknown build error, 'Could not load type 'System.Resources.NeutralResourcesLanguageAttribute' from assembly 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.'
I think – but am not sure – that the issue is that FFME dll is built around .Net 8.0, and is not compatible with .Net Framework 4.8.1 which I, unfortunately, have to use as the windows media element I want to replace is in a very large 4.8.1 project.
Do you happen to know if there is a .NetFramework 4.8.1 version of the dll or if there is a simple way to build the dll so that it works with that framework?
Again, much appreciated.
Saul Greenberg
From: Hans Håkansson ***@***.***>
Sent: November 24, 2024 11:58 AM
To: unosquare/ffmediaelement ***@***.***>
Cc: Saul Greenberg ***@***.***>; Author ***@***.***>
Subject: Re: [unosquare/ffmediaelement] Could not load type 'FFmpeg.AutoGen.Native.LibraryLoader' from assembly 'FFmpeg.AutoGen (Issue #679)
[△EXTERNAL]
I think I understand the problem. The author has not published any new NuGet packages since 2021, but the source code has been updated. If you try to use the published NuGet package, it will be outdated.
To resolve this, you need to clone the repository, build the solution, and obtain the ffme.win.dll assembly. Then, place it in your application's directory and reference it. You should target .NET rather than .NET Framework.
If you clone the repository, there is a working sample application included that you can study:
https://github.com/unosquare/ffmediaelement/tree/master/Unosquare.FFME.Windows.Sample
The FFmpeg binaries can be found here:
https://ffmpeg.org/download.html
That page will link to a few build repositories, such as:
https://github.com/BtbN/FFmpeg-Builds/releases
This particular build works with FFMediaElement:
ffmpeg-n6.1-latest-win64-gpl-shared-6.1.zip<https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n6.1-latest-win64-gpl-shared-6.1.zip>
Note: FFmpeg version 7 is not supported.
|
I guess you need to check-out an earlier commit from when .Net Framework was supported but I think the smartest choice is to look into another library that still has support for .Net Framework like https://github.com/videolan/libvlcsharp And if it is to be integrated into a commercial application, be sure to read the license. FFmpeg includes some components that are licensed under the GPL. |
I had the same issue on my WPF app targetting .net 4.6.1, solved it and my current config is:
4.4.4 64-bit builds can be found at https://github.com/BtbN/FFmpeg-Builds/releases/tag/autobuild-2024-03-31-17-28 |
Thank you Michael,
That did the trick.
I can now run FFME in .Net framework.
To repeat the instructions all in one place, use these versions.
* FFME.Windows NuGet package version 4.4.350
* FFMPEG.AutoGen NuGet package version 4.4.1.1
* FFMPEG build 4.4.4-94-win64-gpl-shared
4.4.4 64-bit builds can be found at https://github.com/BtbN/FFmpeg-Builds/releases/tag/autobuild-2024-03-31-17-28
If targetting 32-bit, you can use https://github.com/defisym/FFmpeg-Builds-Win32/releases/tag/autobuild-2024-03-31-12-42
If using the 64 bit build and Visual Studio, unclick the ‘Prefer 32 bit’ checkbox in the Properties/Buiild options
|
I am considering FFME as an alternate to MediaElement, but can't get it to run correctly.
I wrote a minimal .Net 4.8.2 FFME test project constructed according to the instructions, ie.,
However, it generates this error message:
Could not load type 'FFmpeg.AutoGen.Native.LibraryLoader' from assembly 'FFmpeg.AutoGen, Version=6.0.0.2, Culture=neutral, PublicKeyToken=9b7632533a381715'.
The ffmpeg binaries are numbered as follows, in case this is due to an incompatability with the ffmpeg libraries (although I have also tried with other ffmpeg libraries)
avcodec-61.dll
avdevice-61.dll
avfilter-10.dll
avformat-61.dll
avutil-59.dll
postproc-58.dll
swresample-5.dll
swscale-8.dll
(plus ffmpeg.exe, ffplaye.exe, ffprobe.exe)
Issue Categories
Version Information
Steps to Reproduce
I can package up the entire project as a zip file if desired. It really is a minimal application that jsut attempts to play a single video.
The text was updated successfully, but these errors were encountered: