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

Kernel32 not found (on linux) GetFunctionPointer #109

Closed
1 of 3 tasks
Sebanisu opened this issue Mar 28, 2019 · 7 comments
Closed
1 of 3 tasks

Kernel32 not found (on linux) GetFunctionPointer #109

Sebanisu opened this issue Mar 28, 2019 · 7 comments

Comments

@Sebanisu
Copy link
Contributor

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

  • **I'm submitting a ... **

    • bug report
    • feature request
    • support request or question => Please do not submit support request or questions here, see note at the top of this template.
  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    Format = ffmpeg.avformat_alloc_context();
    Causes
    System.DllNotFoundException: kernel32 at at (wrapper managed-to-native) FFmpeg.AutoGen.Native.WindowsNativeMethods.GetProcAddress(intptr,string) at FFmpeg.AutoGen.Native.FunctionLoader.GetFunctionPointer (System.IntPtr nativeLibraryHandle, System.String functionName) [0x00000] in D:\FFmpeg.AutoGen\FFmpeg.AutoGen\Native\FunctionLoader.cs:55 at FFmpeg.AutoGen.Native.FunctionLoader.GetFunctionDelegate[T] (System.IntPtr nativeLibraryHandle, System.String functionName, System.Boolean throwOnError) [0x00000] in D:\FFmpeg.AutoGen\FFmpeg.AutoGen\Native\FunctionLoader.cs:28 at FFmpeg.AutoGen.ffmpeg.GetFunctionDelegate[T] (System.IntPtr libraryHandle, System.String functionName) [0x00000] in D:\FFmpeg.AutoGen\FFmpeg.AutoGen\FFmpeg.cs:50 at FFmpeg.AutoGen.ffmpeg+<>c.<.cctor>b__4_318 () [0x00000] in D:\FFmpeg.AutoGen\FFmpeg.AutoGen\FFmpeg.functions.export.g.cs:7163 at FFmpeg.AutoGen.ffmpeg.avformat_alloc_context () [0x00000] in D:\FFmpeg.AutoGen\FFmpeg.AutoGen\FFmpeg.functions.export.g.cs:7176 at FF8.FfccVaribleGroup..ctor () [0x0009c] in /home/robert/OpenVIII/FF8/FfccVaribleGroup.cs:53 at FF8.Ffcc..ctor (System.String filename, FFmpeg.AutoGen.AVMediaType mediatype, FF8.Ffcc+FfccMode mode) [0x00008] in /home/robert/OpenVIII/FF8/Ffcc.cs:31 at FF8.Module_movie_test.InitMovie () [0x00001] in /home/robert/OpenVIII/FF8/module_movie_test.cs:160 at FF8.Module_movie_test.Update () [0x000c5] in /home/robert/OpenVIII/FF8/module_movie_test.cs:88 at FF8.ModuleHandler.Update (Microsoft.Xna.Framework.GameTime gameTime) [0x000ac] in /home/robert/OpenVIII/FF8/ModuleHandler.cs:43 at FF8.Game1.Update (Microsoft.Xna.Framework.GameTime gameTime) [0x00030] in /home/robert/OpenVIII/FF8/Game1.cs:69 at Microsoft.Xna.Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime gameTime) [0x00019] in <4fc8466c27384bb19c7b81b2a6a71083>:0 at Microsoft.Xna.Framework.Game.Tick () [0x00103] in <4fc8466c27384bb19c7b81b2a6a71083>:0 at Microsoft.Xna.Framework.SdlGamePlatform.RunLoop () [0x00021] in <4fc8466c27384bb19c7b81b2a6a71083>:0 at Microsoft.Xna.Framework.Game.Run (Microsoft.Xna.Framework.GameRunBehavior runBehavior) [0x0008b] in <4fc8466c27384bb19c7b81b2a6a71083>:0 at Microsoft.Xna.Framework.Game.Run () [0x0000c] in <4fc8466c27384bb19c7b81b2a6a71083>:0 at FF8.Program.Main () [0x00007] in /home/robert/OpenVIII/FF8/Program.cs:17

  • *If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem:

If I try to use any ffmpeg. functions exception occurs.

  • What is the expected behavior?

This function should alloc a avformatcontext

  • What is the motivation / use case for changing the behavior?
    I would like my code to work in linux and windows.
    Currently working fantastically in windows.

  • Please tell us about your environment:
    MonoDevelop 7.7 (build 1869)
    Target framework: .Net Framework 4.6
    FFmpeg.AutoGen 4.1.0.2
    MonoGame.Framework.DesktopGL 3.7.1.189
    MonoGame.Framework.Desktop 3.7.0.7
    MonoGame.Framework.OpenGL 3.7.1.189
    NAudio 1.8.5
    NAudio.Vorbis 1.0.0
    NVorbis 0.8.6

on Ubuntu 18.10 64-bit running on VirtualBox 6.0

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

MaKiPL/OpenVIII-monogame#12 <-- the project i'm working on.
https://stackoverflow.com/questions/55405051/kernel32-not-found-when-using-ffmpeg-autogen-4-1-0-2-in-mono-linux <-- the question I posted on stack overflow.

Sebanisu added a commit to Sebanisu/OpenVIII that referenced this issue Mar 28, 2019
progress on running on linux. Issues with FFmpeg.Autogen.

Ruslan-B/FFmpeg.AutoGen#109
@Sebanisu
Copy link
Contributor Author

Sebanisu commented Mar 28, 2019

I changed the code for GetFunctionPointer
from

private static IntPtr GetFunctionPointer(IntPtr nativeLibraryHandle, string functionName)
        {
#if NET45
            return WindowsNativeMethods.GetProcAddress(nativeLibraryHandle, functionName);
#else
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                return LinuxNativeMethods.dlsym(nativeLibraryHandle, functionName);
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                return MacNativeMethods.dlsym(nativeLibraryHandle, functionName);
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                return WindowsNativeMethods.GetProcAddress(nativeLibraryHandle, functionName);
            throw new PlatformNotSupportedException();
#endif
        }

To this based on LoadNativeLibrary

private static IntPtr GetFunctionPointer(IntPtr nativeLibraryHandle, string functionName)
        {
#if NET45
                switch (LibraryLoader.GetPlatformId())
                {
                    case PlatformID.MacOSX:
                        return MacNativeMethods.dlsym(nativeLibraryHandle, functionName);
                case PlatformID.Unix:
                        return LinuxNativeMethods.dlsym(nativeLibraryHandle, functionName);
                case PlatformID.Win32NT:
                    case PlatformID.Win32S:
                    case PlatformID.Win32Windows:
                        return WindowsNativeMethods.GetProcAddress(nativeLibraryHandle, functionName);
                default:
                        throw new PlatformNotSupportedException();
                }
#else
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                return LinuxNativeMethods.dlsym(nativeLibraryHandle, functionName);
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                return MacNativeMethods.dlsym(nativeLibraryHandle, functionName);
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                return WindowsNativeMethods.GetProcAddress(nativeLibraryHandle, functionName);
            throw new PlatformNotSupportedException();
#endif
        }

The exception is gone though now I only hear sound, no video and it CTD after a while. It's progress I think though.
We're playing video by copying the frame into a bitmap and then into a 2d texture. Drawing it on the screen.
I decode the audio and put the raw bytes into a dynamic sound effect interface.

I'm gonna step through my code see how far it gets before the CTD. I can post more code samples if you want. It's mostly on my Github fork https://github.com/Sebanisu/OpenVIII. I was waiting to pull till i worked out the linux issue.

@Ruslan-B
Copy link
Owner

Well it is quite obvious you are getting wrong platform id from GetPlatformId.
It is possible to override library loading by overriding static delegate ffmpeg. GetOrLoadLibrary so you can call native loading methods from LinuxNativeMethods directly.

@Ruslan-B
Copy link
Owner

Ruslan-B commented Mar 28, 2019

Ignore upper comment. Now I see (reformatted your comment), frankly, speaking we did not expected that someone going to use none .NET Standard version of the library on linux environment. I'll integrate your suggestions in to the repo and update the package.

@Sebanisu
Copy link
Contributor Author

Sebanisu commented Mar 31, 2019

I was wondering if I should do a fork, commit and do a pull request?

Thank you for your time and for this awesome library.

@Ruslan-B
Copy link
Owner

Ruslan-B commented Mar 31, 2019

You can, but I’ll be able to update package next Sunday only. I’m on vacation now and don’t have access to my window machine. (updated comment, as it appears Sunday today 😊)

@Sebanisu
Copy link
Contributor Author

Sebanisu commented Apr 1, 2019

Sorry for the delay, I work on the weekends so I couldn't do the pull request till I got home. Have a good vacation.

@bage2017
Copy link

ffmpeg.autogen rtsp to rtmp?

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