mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-06-30 11:40:47 -07:00
Move code to FFmpegContext
This commit is contained in:
@ -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
|
||||
@ -14,6 +16,8 @@ namespace Ryujinx.Graphics.Nvdec.H264
|
||||
|
||||
public FFmpegContext()
|
||||
{
|
||||
SetRootPath();
|
||||
|
||||
_logFunc = Log;
|
||||
|
||||
// Redirect log output
|
||||
@ -28,6 +32,35 @@ namespace Ryujinx.Graphics.Nvdec.H264
|
||||
_packet = ffmpeg.av_packet_alloc();
|
||||
}
|
||||
|
||||
private 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())
|
||||
|
Reference in New Issue
Block a user