Enable hardware Trickplay processing pipeline for VideoToolbox (#11510)

This commit is contained in:
gnattu authored and GitHub committed 2024-07-17 13:50:32 -04:00
1 parent 8851ace543
commit 5262439300
3 files changed
+51 -2

No files matched your search

@@ -95,6 +95,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
"h264_v4l2m2m",
"h264_videotoolbox",
"hevc_videotoolbox",
"mjpeg_videotoolbox",
"h264_rkmpp",
"hevc_rkmpp"
};
@@ -500,6 +501,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
return output.Contains(keyDesc, StringComparison.Ordinal);
}
public bool CheckSupportedHwaccelFlag(string flag)
{
return !string.IsNullOrEmpty(flag) && GetProcessExitCode(_encoderPath, $"-loglevel quiet -hwaccel_flags +{flag} -hide_banner -f lavfi -i nullsrc=s=1x1:d=100 -f null -");
}
private IEnumerable<string> GetCodecs(Codec codec)
{
string codecstr = codec == Codec.Encoder ? "encoders" : "decoders";
@@ -605,6 +611,31 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
}
private bool GetProcessExitCode(string path, string arguments)
{
using var process = new Process();
process.StartInfo = new ProcessStartInfo(path, arguments)
{
CreateNoWindow = true,
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
ErrorDialog = false
};
_logger.LogDebug("Running {Path} {Arguments}", path, arguments);
try
{
process.Start();
process.WaitForExit();
return process.ExitCode == 0;
}
catch (Exception ex)
{
_logger.LogError("Running {Path} {Arguments} failed with exception {Exception}", path, arguments, ex.Message);
return false;
}
}
[GeneratedRegex("^\\s\\S{6}\\s(?<codec>[\\w|-]+)\\s+.+$", RegexOptions.Multiline)]
private static partial Regex CodecRegex();