fix outputSize

This commit is contained in:
nyanmisaka 2020-08-20 19:08:36 +08:00
parent c23d991c95
commit 54349fc945

View File

@ -1639,37 +1639,47 @@ namespace MediaBrowser.Controller.MediaEncoding
var outputSizeParam = ReadOnlySpan<char>.Empty; var outputSizeParam = ReadOnlySpan<char>.Empty;
var request = state.BaseRequest; var request = state.BaseRequest;
// Add resolution params, if specified
if (request.Width.HasValue
|| request.Height.HasValue
|| request.MaxHeight.HasValue
|| request.MaxWidth.HasValue)
{
outputSizeParam = GetOutputSizeParam(state, options, outputVideoCodec).TrimEnd('"'); outputSizeParam = GetOutputSizeParam(state, options, outputVideoCodec).TrimEnd('"');
// All possible beginning of video filters // All possible beginning of video filters
// Don't break the order // Don't break the order
string[] beginOfParam = new[] string[] beginOfOutputSizeParam = new[]
{ {
// for tonemap_opencl
"hwupload,tonemap_opencl", "hwupload,tonemap_opencl",
// hwupload=extra_hw_frames=64,vpp_qsv (for overlay_qsv on linux)
"hwupload=extra_hw_frames", "hwupload=extra_hw_frames",
// vpp_qsv
"vpp", "vpp",
// hwdownload,format=p010le (hardware decode + software encode for vaapi)
"hwdownload", "hwdownload",
// format=nv12|vaapi,hwupload,scale_vaapi
"format", "format",
// bwdif,scale=expr
"bwdif",
// yadif,scale=expr
"yadif", "yadif",
// scale=expr
"scale" "scale"
}; };
for (int i = 0, index = -1; i < beginOfParam.Length; i++) var index = -1;
foreach (var param in beginOfOutputSizeParam)
{ {
index = outputSizeParam.IndexOf(beginOfParam[i], StringComparison.OrdinalIgnoreCase); index = outputSizeParam.IndexOf(param, StringComparison.OrdinalIgnoreCase);
if (index != -1) if (index != -1)
{ {
outputSizeParam = outputSizeParam.Slice(index); outputSizeParam = outputSizeParam.Slice(index);
break; break;
} }
} }
}
var videoSizeParam = string.Empty; var videoSizeParam = string.Empty;
var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options) ?? string.Empty; var videoDecoder = GetHardwareAcceleratedVideoDecoder(state, options) ?? string.Empty;