Giter Site home page Giter Site logo

Comments (14)

Ruslan-B avatar Ruslan-B commented on May 20, 2024

I wonder what PlatformID you are getting to make it fail.
You can try to workaround by setting DynamicallyLoadedBindings.FunctionResolver = new LinuxFunctionResolver(); before calling DynamicallyLoadedBindings.Initialize().
Please, let me know upon result.

from ffmpeg.autogen.

emmauss avatar emmauss commented on May 20, 2024

GetPlatformId is called here,

EAGAIN = FunctionResolverFactory.GetPlatformId() switch
, in the static constructor. I don't think it can be bypassed.

from ffmpeg.autogen.

emmauss avatar emmauss commented on May 20, 2024

StackTrace

at FFmpeg.AutoGen.FunctionResolverFactory.GetPlatformId()
at FFmpeg.AutoGen.ffmpeg..cctor()

from ffmpeg.autogen.

emmauss avatar emmauss commented on May 20, 2024

image
Although my projects are all Net7, the autogen nuget package is net standard 2.0.

from ffmpeg.autogen.

Ruslan-B avatar Ruslan-B commented on May 20, 2024

Right, I see. I'll do hotfix.

from ffmpeg.autogen.

emmauss avatar emmauss commented on May 20, 2024

I wonder what PlatformID you are getting to make it fail. You can try to workaround by setting DynamicallyLoadedBindings.FunctionResolver = new LinuxFunctionResolver(); before calling DynamicallyLoadedBindings.Initialize(). Please, let me know upon result.

I switched to using DynamicallyLoadedBindings, and the previous error no longer occurs.
Instead it fails on dlopen, as libdl doesn't exist on android,

protected override IntPtr LoadNativeLibrary(string libraryName) => dlopen(libraryName, RTLD_NOW);

from ffmpeg.autogen.

Ruslan-B avatar Ruslan-B commented on May 20, 2024

Well, I guess you are the first one how trying this on android.
You can create a copy of LinuxFunctionResolver with this thing private const string Libdl = "libdl.so"; - i.e. without version suffix.

from ffmpeg.autogen.

Ruslan-B avatar Ruslan-B commented on May 20, 2024

I switched to using DynamicallyLoadedBindings, and the previous error no longer occurs. Instead it fails on dlopen, as libdl doesn't exist on android,

Question here from which set of bindings did you switched?

from ffmpeg.autogen.

emmauss avatar emmauss commented on May 20, 2024

I switched to using DynamicallyLoadedBindings, and the previous error no longer occurs. Instead it fails on dlopen, as libdl doesn't exist 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.

from ffmpeg.autogen.

Ruslan-B avatar Ruslan-B commented on May 20, 2024

I switched to using DynamicallyLoadedBindings, and the previous error no longer occurs. Instead it fails on dlopen, as libdl doesn't exist 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.
we can do zoom session if you like too.

from ffmpeg.autogen.

emmauss avatar emmauss commented on May 20, 2024

Sorry for the misunderstanding. Let me start from the beginning.
The project I'm porting is https://github.com/unosquare/ffmediaelement . It's currently outdated and uses ffmpeg 4.4 and FFMpeg.Autogen 4 nuget package. As the package, and the other Autogen packages were created using netstandard 2.0, and not multitargeting netstandard and net 5+, the exception I reported occurs because of this
image

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.

from ffmpeg.autogen.

Ruslan-B avatar Ruslan-B commented on May 20, 2024

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.

from ffmpeg.autogen.

emmauss avatar emmauss commented on May 20, 2024

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

from ffmpeg.autogen.

Ruslan-B avatar Ruslan-B commented on May 20, 2024

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.

from ffmpeg.autogen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.