diff options
author | Ac_K <Acoustik666@gmail.com> | 2021-05-20 18:28:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-20 18:28:18 +0200 |
commit | 7b8ad1c36ce7d0d9027d89e194d0abc2e879b08b (patch) | |
tree | e619058cb1d855bc46f1749dda9252708b7547ea | |
parent | c316c059ef2ffff40544530dd649c3fa9ef83ec4 (diff) |
ffmpeg: Attempt to fix RootPath on some linux distributions (#2292)
* fix ffmpeg lib path
* Check if ffmpeg isn't found
* Move code to FFmpegContext
* Call it in static constructor
* revert static instance
* rollback
* lazy initialization
* Revert "lazy initialization"
This reverts commit f675d26a5d15ade72e41a5ba899ba80aed3c396d.
-rw-r--r-- | Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs | 36 | ||||
-rw-r--r-- | Ryujinx/Program.cs | 4 |
2 files changed, 36 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs b/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs index c402c574..17de1a03 100644 --- a/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs +++ b/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs @@ -1,6 +1,8 @@ using FFmpeg.AutoGen; using Ryujinx.Common.Logging; using System; +using System.Diagnostics; +using System.IO; using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Nvdec.H264 @@ -28,6 +30,40 @@ namespace Ryujinx.Graphics.Nvdec.H264 _packet = ffmpeg.av_packet_alloc(); } + static FFmpegContext() + { + SetRootPath(); + } + + private static void SetRootPath() + { + if (OperatingSystem.IsLinux()) + { + // Configure FFmpeg search path + Process lddProcess = Process.Start(new ProcessStartInfo + { + FileName = "/bin/sh", + Arguments = "-c \"ldd $(which ffmpeg 2>/dev/null) | grep libavfilter\" 2>/dev/null", + UseShellExecute = false, + RedirectStandardOutput = true + }); + + string lddOutput = lddProcess.StandardOutput.ReadToEnd(); + + lddProcess.WaitForExit(); + lddProcess.Close(); + + if (lddOutput.Contains(" => ")) + { + ffmpeg.RootPath = Path.GetDirectoryName(lddOutput.Split(" => ")[1]); + } + else + { + Logger.Error?.PrintMsg(LogClass.FFmpeg, "FFmpeg wasn't found. Make sure that you have it installed and up to date."); + } + } + } + private void Log(void* p0, int level, string format, byte* vl) { if (level > ffmpeg.av_log_get_level()) diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs index 9600f9dc..fbdea7de 100644 --- a/Ryujinx/Program.cs +++ b/Ryujinx/Program.cs @@ -1,5 +1,4 @@ using ARMeilleure.Translation.PTC; -using FFmpeg.AutoGen; using Gtk; using Ryujinx.Common.Configuration; using Ryujinx.Common.GraphicsDriver; @@ -78,9 +77,6 @@ namespace Ryujinx if (OperatingSystem.IsLinux()) { XInitThreads(); - - // Configure FFmpeg search path - ffmpeg.RootPath = "/lib"; } string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine); |