BogdanovKirill / RtspClientSharp

Pure C# RTSP client for .NET Standard without external dependencies and with true async nature. I welcome contributions.
MIT License
713 stars 286 forks source link

Unable to load DLL 'libffmpeghelper.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) #116

Open danelec-hpm opened 3 years ago

danelec-hpm commented 3 years ago

Describe the bug I cloned the repository, opened in VS 2019 and installed the Windows SDK that was missing. When running the player I am getting the error: System.DllNotFoundException: 'Unable to load DLL 'libffmpeghelper.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)' For some reason the libffmpeghelper.dll is not automatically copied to the players bin/debug folder? I tried to copy it manually, but I am still getting above error.

To Reproduce Clone repo. Build the solution and run the SimpleRtspPlayer sample. Type correct device address, login and password and click Start button. The code fails at FFmpegVideoDecoder.cs line 37: int resultCode = FFmpegVideoPInvoke.CreateVideoDecoder(videoCodecId, out IntPtr decoderPtr);

Expected behavior That the video would just play

Desktop (please complete the following information):

Husseinbeygi commented 2 years ago

Hi I have the same problem.... Did anyone manage to solve that?

danelec-hpm commented 2 years ago

I managed to solve it. You need to set the C++ project to 64 bit. Right click the libffmpeghelper in Visual Studio and select Proerties. Then at the top right, change platform to x64. It should then work

Husseinbeygi commented 2 years ago

After Compiling The libffmpeghelper. Where should I put the DLL to C# project found it? I still get the same error!

danelec-hpm commented 2 years ago

It should be automatically included in the C# project, but if not copy it to the bin/debug or bin/release folder.

Husseinbeygi commented 2 years ago

I did what you said. Still get the same error. I don't know what I'm doing wrong. And I'm Using Asp.net Core 5 on Windows 10

Capture

Husseinbeygi commented 2 years ago

I manage to Solve it 👍 in my case, I need to copy the X64 Folder in the same directory as libffmpeghelper.dll

RoyLaiYi commented 2 years ago

Still cannot work!

nshiggins commented 2 years ago

For me it was the post-build script that copies various DLLs to the build directory that was failing. XCOPY is temperamental and if you have spaces in the path it complains. The solution was to put quotes around the paths:

xcopy "$(ProjectDir)x64*.dll" "$(TargetDir)" /Y /E /C /F xcopy "$(ProjectDir)..\libffmpeghelper\x64\$(Configuration)\libffmpeghelper.dll" "$(TargetDir)" /Y /E /C /F

aslamiqbal commented 1 year ago

@nshiggins thanks for your instructions. It works but showing another error:

"RtspClientSharp.Rtsp.RtspClientException: Receive error ---> 
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. 
(Exception from HRESULT: 0x8007000B)\r\n   at SimpleRtspPlayer.RawFramesDecoding.FFmpeg.FFmpegAudioPInvoke.CreateAudioDecoder
(FFmpegAudioCodecId audioCodecId, Int32 bitsPerCodedSample, IntPtr& handle)\r\n
   at SimpleRtspPlayer.RawFramesDecoding.FFmpeg.FFmpegAudioDecoder.CreateDecoder(FFmpegAudioCodecId audioCodecId, Int32 bitsPerCodedSample) 
   in....\\Examples\\SimpleRtspPlayer\\RawFramesDecoding\\FFmpeg\\FFmpegAudioDecoder.cs:line 38
danelec-hpm commented 1 year ago

@aslamiqbal Sounds like you compiled the project for 64 bit and copied a 32 bit ffmpeg dll file or vise versa. Or you compiled executeable for 64 bit and your Windows is 32 bits.

CanduD commented 8 months ago

Here to revive this thread as I've run into this issue trying to build my own project. Tried following @danelec-hpm steps but still getting the same issue. RtspClientSharp.Rtsp.RtspClientException: Receive error ---> System.DllNotFoundException: Unable to load DLL 'libffmpeghelper.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E).