|
|
|
@ -467,24 +467,26 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
|
|
|
.Append(' ');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (state.IsVideoRequest
|
|
|
|
|
&& string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions);
|
|
|
|
|
var outputVideoCodec = GetVideoEncoder(state, encodingOptions);
|
|
|
|
|
|
|
|
|
|
if(encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv"))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv"))
|
|
|
|
|
{
|
|
|
|
|
arg.Append("-hwaccel qsv ");
|
|
|
|
|
} else {
|
|
|
|
|
arg.Append("-init_hw_device qsv=hw -filter_hw_device hw ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arg.Append(videoDecoder + " ");
|
|
|
|
|
}
|
|
|
|
|
if (state.IsVideoRequest
|
|
|
|
|
&& string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, encodingOptions);
|
|
|
|
|
var outputVideoCodec = GetVideoEncoder(state, encodingOptions);
|
|
|
|
|
|
|
|
|
|
if(encodingOptions.EnableHardwareEncoding && outputVideoCodec.Contains("qsv"))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv"))
|
|
|
|
|
{
|
|
|
|
|
arg.Append("-hwaccel qsv ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
arg.Append("-init_hw_device qsv=hw -filter_hw_device hw ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arg.Append(videoDecoder + " ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arg.Append("-i ")
|
|
|
|
|
.Append(GetInputPathArgument(state));
|
|
|
|
@ -1568,7 +1570,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
|
|
|
if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
&& outputSizeParam.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
outputSizeParam = ",format=nv12|vaapi,hwupload";
|
|
|
|
|
outputSizeParam = ",format=nv12|vaapi,hwupload";
|
|
|
|
|
|
|
|
|
|
// Add parameters to use VAAPI with burn-in subttiles (GH issue #642)
|
|
|
|
|
if (state.SubtitleStream != null
|
|
|
|
@ -1588,12 +1590,14 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
|
|
|
state.VideoStream.Width.Value,
|
|
|
|
|
state.VideoStream.Height.Value);
|
|
|
|
|
|
|
|
|
|
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
videoSizeParam += ",hwupload=extra_hw_frames=64";
|
|
|
|
|
} else {
|
|
|
|
|
videoSizeParam += ":force_original_aspect_ratio=decrease";
|
|
|
|
|
}
|
|
|
|
|
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
videoSizeParam += ",hwupload=extra_hw_frames=64";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
videoSizeParam += ":force_original_aspect_ratio=decrease";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mapPrefix = state.SubtitleStream.IsExternal ?
|
|
|
|
@ -1604,25 +1608,26 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
|
|
|
? 0
|
|
|
|
|
: state.SubtitleStream.Index;
|
|
|
|
|
|
|
|
|
|
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options);
|
|
|
|
|
|
|
|
|
|
var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"";
|
|
|
|
|
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options);
|
|
|
|
|
var retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"";
|
|
|
|
|
|
|
|
|
|
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv"))
|
|
|
|
|
{
|
|
|
|
|
retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\"";
|
|
|
|
|
} else {
|
|
|
|
|
retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]hwupload=extra_hw_frames=64[v];[v][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\"";
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(videoDecoder) && videoDecoder.Contains("qsv"))
|
|
|
|
|
{
|
|
|
|
|
retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\"";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
retStr = " -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}]hwupload=extra_hw_frames=64[v];[v][sub]overlay_qsv=x=(W-w)/2:y=(H-h)/2{3}\"";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Format(
|
|
|
|
|
CultureInfo.InvariantCulture,
|
|
|
|
|
retStr,
|
|
|
|
|
CultureInfo.InvariantCulture,
|
|
|
|
|
retStr,
|
|
|
|
|
mapPrefix,
|
|
|
|
|
subtitleStreamIndex,
|
|
|
|
|
subtitleStreamIndex,
|
|
|
|
|
state.VideoStream.Index,
|
|
|
|
|
outputSizeParam,
|
|
|
|
|
videoSizeParam);
|
|
|
|
@ -1693,7 +1698,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
|
|
|
// output dimensions. Output dimensions are guaranteed to be even.
|
|
|
|
|
var outputWidth = width.Value;
|
|
|
|
|
var outputHeight = height.Value;
|
|
|
|
|
var vaapi_or_qsv = string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) ? "qsv" : "vaapi";
|
|
|
|
|
var vaapi_or_qsv = string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) ? "qsv" : "vaapi";
|
|
|
|
|
|
|
|
|
|
if (!videoWidth.HasValue
|
|
|
|
|
|| outputWidth != videoWidth.Value
|
|
|
|
@ -1707,9 +1712,11 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
|
|
|
vaapi_or_qsv,
|
|
|
|
|
outputWidth,
|
|
|
|
|
outputHeight));
|
|
|
|
|
} else {
|
|
|
|
|
filters.Add(string.Format(CultureInfo.InvariantCulture, "scale_{0}=format=nv12", vaapi_or_qsv));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
filters.Add(string.Format(CultureInfo.InvariantCulture, "scale_{0}=format=nv12", vaapi_or_qsv));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((videoDecoder ?? string.Empty).IndexOf("_cuvid", StringComparison.OrdinalIgnoreCase) != -1
|
|
|
|
|
&& width.HasValue
|
|
|
|
@ -1955,10 +1962,10 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
|
|
|
|
|
|
|
|
// If we are software decoding, and hardware encoding
|
|
|
|
|
if (string.Equals(outputVideoCodec, "h264_qsv", StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
&& (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv")))
|
|
|
|
|
&& (string.IsNullOrEmpty(videoDecoder) || !videoDecoder.Contains("qsv")))
|
|
|
|
|
{
|
|
|
|
|
filters.Add("format=nv12|qsv");
|
|
|
|
|
filters.Add("hwupload=extra_hw_frames=64");
|
|
|
|
|
filters.Add("hwupload=extra_hw_frames=64");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var inputWidth = videoStream?.Width;
|
|
|
|
|