sipsorcery-org / SIPSorceryMedia.FFmpeg

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

How to initialize FFmpeg in .NET MAUI-Windows #77

Closed hossam14102010 closed 1 month ago

hossam14102010 commented 1 month ago

I have installed the bin using winget install "FFmpeg (Shared)" on Windows 11 22631.3810. it installs successfully but when running FFmpegInit.Initialise() I get System.NotSupportedException: 'Specified method is not supported.' I have also tried setting the logLevel to FfmpegLogLevelEnum.AV_LOG_FATAL , and I got the same exception. I tried to set the libPath to C:\Users\UserName\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg.Shared_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-7.0.1-full_build-shared\bin and I got the same exeption

iguanaware commented 1 month ago

I'm getting the same error:

   at FFmpeg.AutoGen.DynamicallyLoadedBindings.<>c.<Initialize>b__2_1244()
   at FFmpeg.AutoGen.DynamicallyLoadedBindings.<>c.<Initialize>b__2_525()
   at FFmpeg.AutoGen.ffmpeg.avdevice_register_all()
   at SIPSorceryMedia.FFmpeg.FFmpegInit.SetFFmpegBinariesPath(String path)
   at SIPSorceryMedia.FFmpeg.FFmpegInit.RegisterFFmpegBinaries(String libPath)
   at SIPSorceryMedia.FFmpeg.FFmpegInit.Initialise(Nullable`1 logLevel, String libPath, ILogger appLogger)
   at demo.Program.CreatePeerConnection(X509Certificate2 cert) in C:\src\sipsorcery\examples\WebRTCExamples\WebRTCTestPatternServer\Program.cs:line 132
   at demo.Program.<>c__DisplayClass7_0.<Main>b__2() in C:\src\sipsorcery\examples\WebRTCExamples\WebRTCTestPatternServer\Program.cs:line 85
   at SIPSorcery.Net.WebRTCWebSocketPeer.<OnOpen>d__19.MoveNext()

I was able to get it working with version 6.0. I haven't tried others yet

PS C:\Users\iguan> winget search --id Gyan.FFmpeg.Shared --versions
Found FFmpeg (Shared) [Gyan.FFmpeg.Shared]
Version
-------
7.0.1
7.0
6.1.1
6.1
6.0
5.1.2
ha-ves commented 1 month ago

same with sipsorcery-org/sipsorcery#1141 right.

Support for FFmpeg 7.x is not yet in sight, in the meantime use FFmpeg 6.x.

hossam14102010 commented 1 month ago

I have tried version 6.0 and 6.1 in a simple .NET console app:

using SIPSorceryMedia.FFmpeg;
FFmpegInit.Initialise();

and I am getting the same Exception

hossam14102010 commented 1 month ago

The problem was the PATH environment variable has value that is set to C:\Users\{UserName}\AppData\Local\Microsoft\WinGet\Links and this directory contains shortcut for FFmpeg.exe, although this works properly when I launch powershell in this directory and type ffmpeg, but this didn't work in the app. so I deleted the shortcuts in this directory and added another value to the PATH environment variable to where the winget installed the package (C:\Users{UserName}\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg.Shared_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-6.0-full_build-shared\bin)