mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-06-26 17:08:05 +02:00
Add advanced options for Intel QSV encoders
This commit is contained in:
parent
22d8806622
commit
1b65c01928
|
@ -896,6 +896,16 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
}
|
}
|
||||||
|
|
||||||
args.Append(GetQsvDeviceArgs(QsvAlias));
|
args.Append(GetQsvDeviceArgs(QsvAlias));
|
||||||
|
|
||||||
|
if (string.Equals(vidEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) && options.EnableIntelLookAheadH264)
|
||||||
|
{
|
||||||
|
args.Append(" -extra_hw_frames=" + options.IntelLookAheadDepthH264);
|
||||||
|
}
|
||||||
|
else if (string.Equals(vidEncoder, "hevc_qsv", StringComparison.OrdinalIgnoreCase) && options.EnableIntelLookAheadHevc)
|
||||||
|
{
|
||||||
|
args.Append(" -extra_hw_frames=" + options.IntelLookAheadDepthHevc);
|
||||||
|
}
|
||||||
|
|
||||||
var filterDevArgs = GetFilterHwDeviceArgs(QsvAlias);
|
var filterDevArgs = GetFilterHwDeviceArgs(QsvAlias);
|
||||||
// child device used by qsv.
|
// child device used by qsv.
|
||||||
if (_mediaEncoder.SupportsHwaccel("vaapi") || _mediaEncoder.SupportsHwaccel("d3d11va"))
|
if (_mediaEncoder.SupportsHwaccel("vaapi") || _mediaEncoder.SupportsHwaccel("d3d11va"))
|
||||||
|
@ -1543,7 +1553,61 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
// Only h264_qsv has look_ahead option
|
// Only h264_qsv has look_ahead option
|
||||||
if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
param += " -look_ahead 0";
|
if (encodingOptions.EnableIntelLookAheadH264)
|
||||||
|
{
|
||||||
|
param += $" -look_ahead 1 -look_ahead_depth {encodingOptions.IntelLookAheadDepthH264}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
param += " -look_ahead 0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodingOptions.EnableIntelExtBrcH264)
|
||||||
|
{
|
||||||
|
param += " -extbrc 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodingOptions.EnableIntelBPyramidH264)
|
||||||
|
{
|
||||||
|
param += " -b_strategy 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodingOptions.EnableIntelAdaptiveIBFramesH264)
|
||||||
|
{
|
||||||
|
param += " -adaptive_i 1 -adaptive_b 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodingOptions.EnableIntelTrellisH264)
|
||||||
|
{
|
||||||
|
param += " -trellis 1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (string.Equals(videoEncoder, "hevc_qsv", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
if (encodingOptions.EnableIntelLookAheadHevc)
|
||||||
|
{
|
||||||
|
param += $" -look_ahead_depth {encodingOptions.IntelLookAheadDepthHevc}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodingOptions.EnableIntelExtBrcHevc)
|
||||||
|
{
|
||||||
|
param += " -extbrc 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodingOptions.EnableIntelBPyramidHevc)
|
||||||
|
{
|
||||||
|
param += " -b_strategy 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodingOptions.EnableIntelAdaptiveIBFramesHevc)
|
||||||
|
{
|
||||||
|
param += " -adaptive_i 1 -adaptive_b 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (encodingOptions.EnableIntelTrellisHevc)
|
||||||
|
{
|
||||||
|
param += " -trellis 1";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (string.Equals(videoEncoder, "h264_nvenc", StringComparison.OrdinalIgnoreCase) // h264 (h264_nvenc)
|
else if (string.Equals(videoEncoder, "h264_nvenc", StringComparison.OrdinalIgnoreCase) // h264 (h264_nvenc)
|
||||||
|
@ -3698,7 +3762,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
|
|
||||||
// qsv requires a fixed pool size.
|
// qsv requires a fixed pool size.
|
||||||
// default to 64 otherwise it will fail on certain iGPU.
|
// default to 64 otherwise it will fail on certain iGPU.
|
||||||
subFilters.Add("hwupload=derive_device=qsv:extra_hw_frames=64");
|
subFilters.Add($"hwupload=derive_device=qsv:extra_hw_frames={GetIntelExtraHwFrames(vidEncoder, options, 64)}");
|
||||||
|
|
||||||
var (overlayW, overlayH) = GetFixedOutputSize(inW, inH, reqW, reqH, reqMaxW, reqMaxH);
|
var (overlayW, overlayH) = GetFixedOutputSize(inW, inH, reqW, reqH, reqMaxW, reqMaxH);
|
||||||
var overlaySize = (overlayW.HasValue && overlayH.HasValue)
|
var overlaySize = (overlayW.HasValue && overlayH.HasValue)
|
||||||
|
@ -3805,7 +3869,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
// allocate extra pool sizes for vaapi vpp
|
// allocate extra pool sizes for vaapi vpp
|
||||||
if (!string.IsNullOrEmpty(hwScaleFilter) && isVaapiDecoder)
|
if (!string.IsNullOrEmpty(hwScaleFilter) && isVaapiDecoder)
|
||||||
{
|
{
|
||||||
hwScaleFilter += ":extra_hw_frames=24";
|
hwScaleFilter += $":extra_hw_frames={GetIntelExtraHwFrames(vidEncoder, options, 24)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// hw scale
|
// hw scale
|
||||||
|
@ -3881,7 +3945,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
// OUTPUT qsv(nv12) surface(vram)
|
// OUTPUT qsv(nv12) surface(vram)
|
||||||
// reverse-mapping via qsv(vaapi)-opencl interop.
|
// reverse-mapping via qsv(vaapi)-opencl interop.
|
||||||
// add extra pool size to avoid the 'cannot allocate memory' error on hevc_qsv.
|
// add extra pool size to avoid the 'cannot allocate memory' error on hevc_qsv.
|
||||||
mainFilters.Add("hwmap=derive_device=qsv:reverse=1:extra_hw_frames=16");
|
mainFilters.Add($"hwmap=derive_device=qsv:reverse=1:extra_hw_frames={GetIntelExtraHwFrames(vidEncoder, options, 16)}");
|
||||||
mainFilters.Add("format=qsv");
|
mainFilters.Add("format=qsv");
|
||||||
}
|
}
|
||||||
else if (isVaapiDecoder)
|
else if (isVaapiDecoder)
|
||||||
|
@ -3914,7 +3978,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
|
|
||||||
// qsv requires a fixed pool size.
|
// qsv requires a fixed pool size.
|
||||||
// default to 64 otherwise it will fail on certain iGPU.
|
// default to 64 otherwise it will fail on certain iGPU.
|
||||||
subFilters.Add("hwupload=derive_device=qsv:extra_hw_frames=64");
|
subFilters.Add($"hwupload=derive_device=qsv:extra_hw_frames={GetIntelExtraHwFrames(vidEncoder, options, 64)}");
|
||||||
|
|
||||||
var (overlayW, overlayH) = GetFixedOutputSize(inW, inH, reqW, reqH, reqMaxW, reqMaxH);
|
var (overlayW, overlayH) = GetFixedOutputSize(inW, inH, reqW, reqH, reqMaxW, reqMaxH);
|
||||||
var overlaySize = (overlayW.HasValue && overlayH.HasValue)
|
var overlaySize = (overlayW.HasValue && overlayH.HasValue)
|
||||||
|
@ -4087,7 +4151,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
// allocate extra pool sizes for vaapi vpp
|
// allocate extra pool sizes for vaapi vpp
|
||||||
if (!string.IsNullOrEmpty(hwScaleFilter))
|
if (!string.IsNullOrEmpty(hwScaleFilter))
|
||||||
{
|
{
|
||||||
hwScaleFilter += ":extra_hw_frames=24";
|
hwScaleFilter += $":extra_hw_frames={GetIntelExtraHwFrames(vidEncoder, options, 24)}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// hw scale
|
// hw scale
|
||||||
|
@ -6106,5 +6170,19 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||||
{
|
{
|
||||||
return string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase);
|
return string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetIntelExtraHwFrames(string vidEncoder, EncodingOptions options, int initialExtraHwFrames)
|
||||||
|
{
|
||||||
|
if (string.Equals(vidEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) && options.EnableIntelLookAheadH264)
|
||||||
|
{
|
||||||
|
initialExtraHwFrames += options.IntelLookAheadDepthH264;
|
||||||
|
}
|
||||||
|
else if (string.Equals(vidEncoder, "hevc_qsv", StringComparison.OrdinalIgnoreCase) && options.EnableIntelLookAheadHevc)
|
||||||
|
{
|
||||||
|
initialExtraHwFrames += options.IntelLookAheadDepthHevc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return initialExtraHwFrames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,19 @@ public class EncodingOptions
|
||||||
EnableEnhancedNvdecDecoder = true;
|
EnableEnhancedNvdecDecoder = true;
|
||||||
PreferSystemNativeHwDecoder = true;
|
PreferSystemNativeHwDecoder = true;
|
||||||
EnableIntelLowPowerH264HwEncoder = false;
|
EnableIntelLowPowerH264HwEncoder = false;
|
||||||
|
EnableIntelLookAheadH264 = false;
|
||||||
|
IntelLookAheadDepthH264 = 60;
|
||||||
|
EnableIntelExtBrcH264 = false;
|
||||||
|
EnableIntelBPyramidH264 = false;
|
||||||
|
EnableIntelAdaptiveIBFramesH264 = false;
|
||||||
|
EnableIntelTrellisH264 = false;
|
||||||
EnableIntelLowPowerHevcHwEncoder = false;
|
EnableIntelLowPowerHevcHwEncoder = false;
|
||||||
|
EnableIntelLookAheadHevc = false;
|
||||||
|
IntelLookAheadDepthHevc = 60;
|
||||||
|
EnableIntelExtBrcHevc = false;
|
||||||
|
EnableIntelBPyramidHevc = false;
|
||||||
|
EnableIntelAdaptiveIBFramesHevc = false;
|
||||||
|
EnableIntelTrellisHevc = false;
|
||||||
EnableHardwareEncoding = true;
|
EnableHardwareEncoding = true;
|
||||||
AllowHevcEncoding = false;
|
AllowHevcEncoding = false;
|
||||||
EnableSubtitleExtraction = true;
|
EnableSubtitleExtraction = true;
|
||||||
|
@ -222,11 +234,71 @@ public class EncodingOptions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableIntelLowPowerH264HwEncoder { get; set; }
|
public bool EnableIntelLowPowerH264HwEncoder { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether LookAhead should be used for Intel H264 encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelLookAheadH264 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating the number of frames that should be used for LookAhead with Intel H264 encoder.
|
||||||
|
/// </summary>
|
||||||
|
public int IntelLookAheadDepthH264 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether ExtBrc should be used for Intel H264 encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelExtBrcH264 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether B-Pyramid should be used for Intel H264 encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelBPyramidH264 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Adaptive I/B frames should be used for Intel H264 encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelAdaptiveIBFramesH264 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Trellis quantization should be used for Intel H264 encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelTrellisH264 { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether the Intel HEVC low-power hardware encoder should be used.
|
/// Gets or sets a value indicating whether the Intel HEVC low-power hardware encoder should be used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableIntelLowPowerHevcHwEncoder { get; set; }
|
public bool EnableIntelLowPowerHevcHwEncoder { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether LookAhead should be used for Intel HEVC encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelLookAheadHevc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating the number of frames that should be used for LookAhead with Intel HEVC encoder.
|
||||||
|
/// </summary>
|
||||||
|
public int IntelLookAheadDepthHevc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether ExtBrc should be used for Intel HEVC encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelExtBrcHevc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether B-Pyramid should be used for Intel HEVC encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelBPyramidHevc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Adaptive I/B frames should be used for Intel HEVC encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelAdaptiveIBFramesHevc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Trellis quantization should be used for Intel HEVC encoder.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIntelTrellisHevc { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether hardware encoding is enabled.
|
/// Gets or sets a value indicating whether hardware encoding is enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue