sipsorcery-org / SIPSorceryMedia.FFmpeg

GNU Lesser General Public License v2.1
33 stars 24 forks source link

Unable to load DLL #6

Closed R0manych closed 2 years ago

R0manych commented 2 years ago

avpriv_mpeg4audio_get_config2 Not found in DLL Unable to load DLL 'avformat.58 under The specified module could not be found In FileSourceDecoder,InitialiseSource line 70 _fmtCtx = ffmpeg.avformat_alloc_context();

SIPSorceryMedia.FFmpeg.FileSourceDecoder.InitialiseSource() в FileSourceDecoder.cs SIPSorceryMedia.FFmpeg.FileSourceDecoder.StartDecode() в FileSourceDecoder.cs SIPSorceryMedia.FFmpeg.FFmpegFileSource.Start() в FFmpegFileSource.cs SIPSorceryMedia.FFmpeg.FFmpegFileSource.StartVideo() в FFmpegFileSource.cs VideofileStreamingConsole.Program.CreatePeerConnectionNew.AnonymousMethod__1(SIPSorcery.Net.RTCPeerConnectionState) в Program.cs

My code:

 private static async Task<RTCPeerConnection> CreatePeerConnection()
        {
            RTCConfiguration config = new RTCConfiguration
            {
                iceServers = new List<RTCIceServer> { new RTCIceServer { urls = STUN_URL } }
            };
            var pc = new RTCPeerConnection(config);
            FFmpegInit.Initialise(FfmpegLogLevelEnum.AV_LOG_VERBOSE);

            var testPattern = new FFmpegFileSource("C:\\Users\\rcher\\Videos\\big-buck-bunny_trailer.webm", false, new AudioEncoder());

            MediaStreamTrack videoTrack = new MediaStreamTrack(testPattern.GetVideoSourceFormats(), MediaStreamStatusEnum.SendRecv);
            pc.addTrack(videoTrack);

            testPattern.OnVideoSourceEncodedSample += pc.SendVideo;
            pc.OnVideoFormatsNegotiated += (videoFormats) => testPattern.SetVideoSourceFormat(videoFormats.First());

            pc.onconnectionstatechange += async (state) =>
            {
                logger.LogDebug($"Peer connection state change to {state}.");

                if (state == RTCPeerConnectionState.connected)
                {
                    await testPattern.StartVideo();
                }
                else if (state == RTCPeerConnectionState.failed)
                {
                    pc.Close("ice disconnection");
                }
                else if (state == RTCPeerConnectionState.closed)
                {
                    await testPattern.CloseVideo();
                }
            };
            return pc;
        }

I don't know what I've done wrong, can you please help? Tried to add all av-dlls into bin\Debug\netcoreapp3.1\FFmpeg\bin\x64

sipsorcery commented 2 years ago

I think something has gone awry with either the nuget packaging or the way dotnet is now unwrapping them. I was able to solve the same problem on one of my examples by using:

SIPSorceryMedia.FFmpeg.FFmpegInit.Initialise(SIPSorceryMedia.FFmpeg.FfmpegLogLevelEnum.AV_LOG_VERBOSE, Environment.CurrentDirectory);

ChristopheI commented 2 years ago

I will close the issue, as it seems solved.

Feel free to ask any other question, or reopen issue.