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

SIPSorceryMedia.Encoder BadImageFormatException/EntryPointNotFoundException #698

Open
ghost opened this issue Mar 2, 2022 · 9 comments
Open

Comments

@ghost
Copy link

ghost commented Mar 2, 2022

Hi Experts,

I am using SIPSorceryMedia.Encoder for streaming image frames as video and facing following problem.

  1. Nuget manager is adding vpxmd.dll x64 version for SIPSorceryMedia.Encoder when built for x86 target application. This caused BadImageFormatException.
  2. I found x86 version of vpxmd.dll from https://www.nuget.org/packages/SIPSorceryMedia.Encoders/0.0.10-pre. When I replace x64 version with x86 downloaded from nuget page, I am now getting EntryPointNotFoundException.
  3. When I check the dll functions using dependency walker, I don't see functions list for x86 dll.

Any pointer would help.

regards,
Suresh

@sipsorcery
Copy link
Member

sipsorcery commented Mar 2, 2022

Sounds like it could be a ABI compatability issue. If your C runtime is different to the one I built the dll with you can get these sort of problems.

Before going down that path below do a search of the issues. I do recall seeing this come up previously. Maybe that will provide an easier solution.

You can build a verion of the vpxmd.dll that matched your system using the instructions here.

@vishal2097
Copy link

Hi,
I'm facing similar issue. Tried executing mentioned steps.
But while executing below cmd for generating 32 bit vpxmd.dll
'../configure --disable-static --disable-examples --disable-tools --disable-docs --target=x86-win32-vs16'
getting exception as 'configure' is not recognized as an internal or external command'.
For that tried setting up MSYS, but getting 'SSL certificate problem: unable to get local issuer certificate'
even after adding ssl certificate.
Any step I'm missing while execution?
Any pointer would help.
Thanks

@sipsorcery
Copy link
Member

Try using WSL, it's way better than msys or cygwin.

libvpx_build

@vishal2097
Copy link

vishal2097 commented Mar 10, 2022

Hi,

Thank you for your Solution , In WSL "./configure --disable-static --disable-examples --disable-tools --disable-docs --target=x86-win32-vs17'" executed Successfully.
vpx.sln is also generated. By following other steps I build 32 bit vpxmd.dll in Visual Studio 19. when I used 32 bit vpxmd.dll I got below exception .

Unhandled Exception: System.ApplicationException: Failed to initialise VP8 encoder, ABI version mismatch.
at SIPSorceryMedia.Encoders.Codecs.Vp8Codec.InitialiseEncoder(UInt32 width, UInt32 height)
at SIPSorceryMedia.Encoders.VpxVideoEncoder.EncodeVideo(Int32 width, Int32 height, Byte[] sample, VideoPixelFormatsEnum pixelFormat, VideoCodecsEnum codec)
at SIPSorceryMedia.Encoders.VideoEncoderEndPoint.ExternalVideoSourceRawSample(UInt32 durationMilliseconds, Int32 width, Int32 height, Byte[] sample, VideoPixelFormatsEnum pixelFormat)

From SIPSorceryMedia.Encoders got to know that VPX_ENCODER_ABI_VERSION = 23
can you please suggest me in which Visual studio version should I use to build vpxmd.dll so that I will not get ABI mismatch exception. or Any step I'm missing while execution?
Any pointer would help.

Thanks

@sipsorcery
Copy link
Member

I would have built the nuget package with Visual Studio 2019 and probably C++ SDK version v1.41.

You don't need to use my verison though. If you can build vpxmd.dll then you can rebuild the .NET SIPSorceryMediaEncoders assembly using it. That way you can guarantee that all the relevant dll's are using the same SDK version.

According to this article, since Visual Studio 2015 ABI has been preserved. If you install the latest Microsoft C++ runtime you should be able to run an app, or consume a library built with any version of the msvc toolset sicne VS 2015.

I'm not completely convinced by the above article though. I regularly build another C++ prioject that uses a bunch of vcpkg dependencies. It's happended quite a few times that an updte to Visual Studio results in an ABI issue with one of the dependencies requiring them all o be rebuilt.

This scenario is the biggest pain point with C++. Rebuilding complete dependency tress is not fun. It's why .NET is so great, that whole category of problems go away. For libvpx the hope is that one day VP8.Net will be production ready and vpxmd.dll will no longer be required.

@vishal2097
Copy link

Hi,
sorry to bother you again

I have followed the approach you mentioned, but still facing same exception, can you please share VS build version details which is being used for building sipsorcery dll and related other dlls.

Thanks

@sipsorcery
Copy link
Member

Visual Studio 2019 Community Edition
My linker at the time I built the dll's using in the SIPSorceryMedia.Encoder nuget package was: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX86\x86\link.exe

@ghost
Copy link
Author

ghost commented Mar 30, 2022

What is the platform toolset used in VS 2019. I still get
Unhandled Exception: System.ApplicationException: Failed to initialise VP8 encoder, ABI version mismatch.
at SIPSorceryMedia.Encoders.Codecs.Vp8Codec.InitialiseEncoder(UInt32 width, UInt32 height) in
..\SIPSorceryMedia.Encoders-master\src\codecs\Vp8Codec.cs:line 107

Visual Studio 2019 is used with WSL. Thank you for the support

@lamposu
Copy link

lamposu commented Jan 7, 2023

I run into this issue also, anyone can help? i have build vpxmd.dll using the instructions here. Do i need to regen the "vpxmd.g.cs"? i follow the "Vpx.AutoGen" project but failed, only get he empty "Std.cs" file...

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