mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-20 07:45:26 +03:00
Enable hardware Trickplay processing pipeline for VideoToolbox (#11510)
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user