mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-16 14:03:03 +03:00
Merge pull request #11511 from jellyfin/trickplay-keyframe-only
This commit is contained in:
@@ -813,12 +813,28 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
int? threads,
|
||||
int? qualityScale,
|
||||
ProcessPriorityClass? priority,
|
||||
bool enableKeyFrameOnlyExtraction,
|
||||
EncodingHelper encodingHelper,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var options = allowHwAccel ? _configurationManager.GetEncodingOptions() : new EncodingOptions();
|
||||
threads ??= _threads;
|
||||
|
||||
if (allowHwAccel && enableKeyFrameOnlyExtraction)
|
||||
{
|
||||
var supportsKeyFrameOnly = (string.Equals(options.HardwareAccelerationType, "nvenc", StringComparison.OrdinalIgnoreCase) && options.EnableEnhancedNvdecDecoder)
|
||||
|| (string.Equals(options.HardwareAccelerationType, "amf", StringComparison.OrdinalIgnoreCase) && OperatingSystem.IsWindows())
|
||||
|| (string.Equals(options.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase) && options.PreferSystemNativeHwDecoder)
|
||||
|| string.Equals(options.HardwareAccelerationType, "vaapi", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(options.HardwareAccelerationType, "videotoolbox", StringComparison.OrdinalIgnoreCase);
|
||||
if (!supportsKeyFrameOnly)
|
||||
{
|
||||
// Disable hardware acceleration when the hardware decoder does not support keyframe only mode.
|
||||
allowHwAccel = false;
|
||||
options = new EncodingOptions();
|
||||
}
|
||||
}
|
||||
|
||||
// A new EncodingOptions instance must be used as to not disable HW acceleration for all of Jellyfin.
|
||||
// Additionally, we must set a few fields without defaults to prevent null pointer exceptions.
|
||||
if (!allowHwAccel)
|
||||
@@ -868,6 +884,11 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
inputArg = "-threads " + threads + " " + inputArg; // HW accel args set a different input thread count, only set if disabled
|
||||
}
|
||||
|
||||
if (enableKeyFrameOnlyExtraction)
|
||||
{
|
||||
inputArg = "-skip_frame nokey " + inputArg;
|
||||
}
|
||||
|
||||
var filterParam = encodingHelper.GetVideoProcessingFilterParam(jobState, options, vidEncoder).Trim();
|
||||
if (string.IsNullOrWhiteSpace(filterParam))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user