-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
ffmpeg static class fails to initialize on mobile. #260
Comments
I wonder what |
FFmpeg.AutoGen/FFmpeg.AutoGen/FFmpeg.cs Line 17 in 15d15bd
|
StackTrace
|
Right, I see. I'll do hotfix. |
I switched to using DynamicallyLoadedBindings, and the previous error no longer occurs. FFmpeg.AutoGen/FFmpeg.AutoGen.Bindings.DynamicallyLoaded/Native/LinuxFunctionResolver.cs Line 14 in 534a3eb
|
Well, I guess you are the first one how trying this on android. |
Question here from which set of bindings did you switched? |
I was using the legacy Autogen. I'm modifying an existing library to work on android, and it was made a while ago. |
focus my friend and give us details, as I have no understanding how and what runs dotNET on android now. |
Sorry for the misunderstanding. Let me start from the beginning. I switched to using https://www.nuget.org/packages/FFmpeg.AutoGen.Bindings.DynamicallyLoaded, updating ffmpeg to 6.0, and setting the resolver manually. This avoids the previous crash, but the Linux resolver doesn't work on android because libdl isn't provided with the android system. This is an issue from android and not dotnet, but the sdk provides ways to dynamically load libraries packaged in your app at runtime. So I made a custom resolver that uses dotnet's NativeLibrary and that works quite well. internal class AndroidFunctionResolver : FunctionResolverBase
{
protected override nint GetFunctionPointer(nint nativeLibraryHandle, string functionName)
{
var func = NativeLibrary.GetExport(nativeLibraryHandle, functionName);
return func;
}
protected override string GetNativeLibraryName(string libraryName, int version) => $"lib{libraryName}.so";
protected override nint LoadNativeLibrary(string libraryName)
{
var lib = NativeLibrary.Load(libraryName);
return lib;
}
} The original project was ported to a cross platform toolkit, so it doesn't rely on wpf. the port isn't public at this moment so I can't share much. |
Well great if you manage to solve the issue, I guess we can close this topic - however would be nice if you share what is behind NativeLibrary call, if some one will try android once again. |
NativeLibrary is dotnets loader. https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.nativelibrary?source=recommendations&view=net-7.0 |
I'll try to address this in upcoming update. Wrt to 7.0 we have another issue #254 - I'll look into it when earlier issues will be solved. |
how to setup the rootpath? |
Trying to use it on Android here. I followed the approach to create the FFmpeg.AutoGen/FFmpeg.AutoGen/FFmpeg.cs Line 17 in 28e5e18
|
dose you use it in unity? |
Nope. Using it on MAUI. I just realized I must move from |
I'll make possible to do a platform loader override within few days. However, I see you have a workaround. |
Note: for support questions, please use stackoverflow or special repository on [github.com](in special repository github.com). This repository's issues are reserved for feature requests and bug reports.
**I'm submitting a ... **
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
ffmpeg static class fails to initialize on non desktop platforms, eg. Android. The line where it throws a PlatfromNotSupportedException is,
FFmpeg.AutoGen/FFmpeg.AutoGen/FunctionResolverFactory.cs
Line 15 in 534a3eb
*If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem:
What is the expected behavior?
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
The text was updated successfully, but these errors were encountered: