|
@@ -557,7 +557,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
{
|
|
{
|
|
return Array.FindIndex(_videoProfilesH264, x => string.Equals(x, profile, StringComparison.OrdinalIgnoreCase));
|
|
return Array.FindIndex(_videoProfilesH264, x => string.Equals(x, profile, StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
}
|
|
- else if (string.Equals("hevc", videoCodec, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+
|
|
|
|
+ if (string.Equals("hevc", videoCodec, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
return Array.FindIndex(_videoProfilesH265, x => string.Equals(x, profile, StringComparison.OrdinalIgnoreCase));
|
|
return Array.FindIndex(_videoProfilesH265, x => string.Equals(x, profile, StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
}
|
|
@@ -1109,19 +1110,19 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
{
|
|
{
|
|
return "-bsf:v h264_mp4toannexb";
|
|
return "-bsf:v h264_mp4toannexb";
|
|
}
|
|
}
|
|
- else if (IsH265(stream))
|
|
|
|
|
|
+
|
|
|
|
+ if (IsH265(stream))
|
|
{
|
|
{
|
|
return "-bsf:v hevc_mp4toannexb";
|
|
return "-bsf:v hevc_mp4toannexb";
|
|
}
|
|
}
|
|
- else if (IsAAC(stream))
|
|
|
|
|
|
+
|
|
|
|
+ if (IsAAC(stream))
|
|
{
|
|
{
|
|
// Convert adts header(mpegts) to asc header(mp4).
|
|
// Convert adts header(mpegts) to asc header(mp4).
|
|
return "-bsf:a aac_adtstoasc";
|
|
return "-bsf:a aac_adtstoasc";
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
public static string GetAudioBitStreamArguments(EncodingJobInfo state, string segmentContainer, string mediaSourceContainer)
|
|
public static string GetAudioBitStreamArguments(EncodingJobInfo state, string segmentContainer, string mediaSourceContainer)
|
|
@@ -1199,10 +1200,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
{
|
|
{
|
|
return FormattableString.Invariant($" -rc_mode CBR -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
|
|
return FormattableString.Invariant($" -rc_mode CBR -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- return FormattableString.Invariant($" -rc_mode VBR -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ return FormattableString.Invariant($" -rc_mode VBR -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
|
|
}
|
|
}
|
|
|
|
|
|
return FormattableString.Invariant($" -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
|
|
return FormattableString.Invariant($" -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}");
|
|
@@ -2762,79 +2761,76 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
widthParam,
|
|
widthParam,
|
|
heightParam);
|
|
heightParam);
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- return GetFixedSwScaleFilter(threedFormat, requestedWidth.Value, requestedHeight.Value);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ return GetFixedSwScaleFilter(threedFormat, requestedWidth.Value, requestedHeight.Value);
|
|
}
|
|
}
|
|
|
|
|
|
// If Max dimensions were supplied, for width selects lowest even number between input width and width req size and selects lowest even number from in width*display aspect and requested size
|
|
// If Max dimensions were supplied, for width selects lowest even number between input width and width req size and selects lowest even number from in width*display aspect and requested size
|
|
- else if (requestedMaxWidth.HasValue && requestedMaxHeight.HasValue)
|
|
|
|
|
|
+
|
|
|
|
+ if (requestedMaxWidth.HasValue && requestedMaxHeight.HasValue)
|
|
{
|
|
{
|
|
var maxWidthParam = requestedMaxWidth.Value.ToString(CultureInfo.InvariantCulture);
|
|
var maxWidthParam = requestedMaxWidth.Value.ToString(CultureInfo.InvariantCulture);
|
|
var maxHeightParam = requestedMaxHeight.Value.ToString(CultureInfo.InvariantCulture);
|
|
var maxHeightParam = requestedMaxHeight.Value.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
return string.Format(
|
|
return string.Format(
|
|
- CultureInfo.InvariantCulture,
|
|
|
|
- "scale=trunc(min(max(iw\\,ih*a)\\,min({0}\\,{1}*a))/{2})*{2}:trunc(min(max(iw/a\\,ih)\\,min({0}/a\\,{1}))/2)*2",
|
|
|
|
- maxWidthParam,
|
|
|
|
- maxHeightParam,
|
|
|
|
- scaleVal);
|
|
|
|
|
|
+ CultureInfo.InvariantCulture,
|
|
|
|
+ "scale=trunc(min(max(iw\\,ih*a)\\,min({0}\\,{1}*a))/{2})*{2}:trunc(min(max(iw/a\\,ih)\\,min({0}/a\\,{1}))/2)*2",
|
|
|
|
+ maxWidthParam,
|
|
|
|
+ maxHeightParam,
|
|
|
|
+ scaleVal);
|
|
}
|
|
}
|
|
|
|
|
|
// If a fixed width was requested
|
|
// If a fixed width was requested
|
|
- else if (requestedWidth.HasValue)
|
|
|
|
|
|
+ if (requestedWidth.HasValue)
|
|
{
|
|
{
|
|
if (threedFormat.HasValue)
|
|
if (threedFormat.HasValue)
|
|
{
|
|
{
|
|
// This method can handle 0 being passed in for the requested height
|
|
// This method can handle 0 being passed in for the requested height
|
|
return GetFixedSwScaleFilter(threedFormat, requestedWidth.Value, 0);
|
|
return GetFixedSwScaleFilter(threedFormat, requestedWidth.Value, 0);
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- var widthParam = requestedWidth.Value.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
|
|
- return string.Format(
|
|
|
|
- CultureInfo.InvariantCulture,
|
|
|
|
- "scale={0}:trunc(ow/a/2)*2",
|
|
|
|
- widthParam);
|
|
|
|
- }
|
|
|
|
|
|
+ var widthParam = requestedWidth.Value.ToString(CultureInfo.InvariantCulture);
|
|
|
|
+
|
|
|
|
+ return string.Format(
|
|
|
|
+ CultureInfo.InvariantCulture,
|
|
|
|
+ "scale={0}:trunc(ow/a/2)*2",
|
|
|
|
+ widthParam);
|
|
}
|
|
}
|
|
|
|
|
|
// If a fixed height was requested
|
|
// If a fixed height was requested
|
|
- else if (requestedHeight.HasValue)
|
|
|
|
|
|
+ if (requestedHeight.HasValue)
|
|
{
|
|
{
|
|
var heightParam = requestedHeight.Value.ToString(CultureInfo.InvariantCulture);
|
|
var heightParam = requestedHeight.Value.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
return string.Format(
|
|
return string.Format(
|
|
- CultureInfo.InvariantCulture,
|
|
|
|
- "scale=trunc(oh*a/{1})*{1}:{0}",
|
|
|
|
- heightParam,
|
|
|
|
- scaleVal);
|
|
|
|
|
|
+ CultureInfo.InvariantCulture,
|
|
|
|
+ "scale=trunc(oh*a/{1})*{1}:{0}",
|
|
|
|
+ heightParam,
|
|
|
|
+ scaleVal);
|
|
}
|
|
}
|
|
|
|
|
|
// If a max width was requested
|
|
// If a max width was requested
|
|
- else if (requestedMaxWidth.HasValue)
|
|
|
|
|
|
+ if (requestedMaxWidth.HasValue)
|
|
{
|
|
{
|
|
var maxWidthParam = requestedMaxWidth.Value.ToString(CultureInfo.InvariantCulture);
|
|
var maxWidthParam = requestedMaxWidth.Value.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
return string.Format(
|
|
return string.Format(
|
|
- CultureInfo.InvariantCulture,
|
|
|
|
- "scale=trunc(min(max(iw\\,ih*a)\\,{0})/{1})*{1}:trunc(ow/a/2)*2",
|
|
|
|
- maxWidthParam,
|
|
|
|
- scaleVal);
|
|
|
|
|
|
+ CultureInfo.InvariantCulture,
|
|
|
|
+ "scale=trunc(min(max(iw\\,ih*a)\\,{0})/{1})*{1}:trunc(ow/a/2)*2",
|
|
|
|
+ maxWidthParam,
|
|
|
|
+ scaleVal);
|
|
}
|
|
}
|
|
|
|
|
|
// If a max height was requested
|
|
// If a max height was requested
|
|
- else if (requestedMaxHeight.HasValue)
|
|
|
|
|
|
+ if (requestedMaxHeight.HasValue)
|
|
{
|
|
{
|
|
var maxHeightParam = requestedMaxHeight.Value.ToString(CultureInfo.InvariantCulture);
|
|
var maxHeightParam = requestedMaxHeight.Value.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
|
return string.Format(
|
|
return string.Format(
|
|
- CultureInfo.InvariantCulture,
|
|
|
|
- "scale=trunc(oh*a/{1})*{1}:min(max(iw/a\\,ih)\\,{0})",
|
|
|
|
- maxHeightParam,
|
|
|
|
- scaleVal);
|
|
|
|
|
|
+ CultureInfo.InvariantCulture,
|
|
|
|
+ "scale=trunc(oh*a/{1})*{1}:min(max(iw/a\\,ih)\\,{0})",
|
|
|
|
+ maxHeightParam,
|
|
|
|
+ scaleVal);
|
|
}
|
|
}
|
|
|
|
|
|
return string.Empty;
|
|
return string.Empty;
|
|
@@ -2908,18 +2904,21 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
"yadif_cuda={0}:-1:0",
|
|
"yadif_cuda={0}:-1:0",
|
|
doubleRateDeint ? "1" : "0");
|
|
doubleRateDeint ? "1" : "0");
|
|
}
|
|
}
|
|
- else if (hwDeintSuffix.Contains("vaapi", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+
|
|
|
|
+ if (hwDeintSuffix.Contains("vaapi", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
return string.Format(
|
|
return string.Format(
|
|
CultureInfo.InvariantCulture,
|
|
CultureInfo.InvariantCulture,
|
|
"deinterlace_vaapi=rate={0}",
|
|
"deinterlace_vaapi=rate={0}",
|
|
doubleRateDeint ? "field" : "frame");
|
|
doubleRateDeint ? "field" : "frame");
|
|
}
|
|
}
|
|
- else if (hwDeintSuffix.Contains("qsv", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+
|
|
|
|
+ if (hwDeintSuffix.Contains("qsv", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
return "deinterlace_qsv=mode=2";
|
|
return "deinterlace_qsv=mode=2";
|
|
}
|
|
}
|
|
- else if (hwDeintSuffix.Contains("videotoolbox", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+
|
|
|
|
+ if (hwDeintSuffix.Contains("videotoolbox", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
return string.Format(
|
|
return string.Format(
|
|
CultureInfo.InvariantCulture,
|
|
CultureInfo.InvariantCulture,
|
|
@@ -2950,7 +2949,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
options.VppTonemappingBrightness,
|
|
options.VppTonemappingBrightness,
|
|
options.VppTonemappingContrast);
|
|
options.VppTonemappingContrast);
|
|
}
|
|
}
|
|
- else if (string.Equals(hwTonemapSuffix, "vulkan", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+
|
|
|
|
+ if (string.Equals(hwTonemapSuffix, "vulkan", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
args = "libplacebo=format={1}:tonemapping={2}:color_primaries=bt709:color_trc=bt709:colorspace=bt709:peak_detect=0:upscaler=none:downscaler=none";
|
|
args = "libplacebo=format={1}:tonemapping={2}:color_primaries=bt709:color_trc=bt709:colorspace=bt709:peak_detect=0:upscaler=none:downscaler=none";
|
|
|
|
|
|
@@ -4826,26 +4826,27 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
{
|
|
{
|
|
return videoStream.BitDepth.Value;
|
|
return videoStream.BitDepth.Value;
|
|
}
|
|
}
|
|
- else if (string.Equals(videoStream.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
|
|
|
|
- || string.Equals(videoStream.PixelFormat, "yuvj420p", StringComparison.OrdinalIgnoreCase)
|
|
|
|
- || string.Equals(videoStream.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+
|
|
|
|
+ if (string.Equals(videoStream.PixelFormat, "yuv420p", StringComparison.OrdinalIgnoreCase)
|
|
|
|
+ || string.Equals(videoStream.PixelFormat, "yuvj420p", StringComparison.OrdinalIgnoreCase)
|
|
|
|
+ || string.Equals(videoStream.PixelFormat, "yuv444p", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
return 8;
|
|
return 8;
|
|
}
|
|
}
|
|
- else if (string.Equals(videoStream.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase)
|
|
|
|
- || string.Equals(videoStream.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+
|
|
|
|
+ if (string.Equals(videoStream.PixelFormat, "yuv420p10le", StringComparison.OrdinalIgnoreCase)
|
|
|
|
+ || string.Equals(videoStream.PixelFormat, "yuv444p10le", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
return 10;
|
|
return 10;
|
|
}
|
|
}
|
|
- else if (string.Equals(videoStream.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase)
|
|
|
|
- || string.Equals(videoStream.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+
|
|
|
|
+ if (string.Equals(videoStream.PixelFormat, "yuv420p12le", StringComparison.OrdinalIgnoreCase)
|
|
|
|
+ || string.Equals(videoStream.PixelFormat, "yuv444p12le", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
return 12;
|
|
return 12;
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- return 8;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ return 8;
|
|
}
|
|
}
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
@@ -5077,11 +5078,9 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty)
|
|
return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty)
|
|
+ (nvdecNoInternalCopy ? " -hwaccel_flags +unsafe_output" : string.Empty) + " -threads 1" + (isAv1 ? " -c:v av1" : string.Empty);
|
|
+ (nvdecNoInternalCopy ? " -hwaccel_flags +unsafe_output" : string.Empty) + " -threads 1" + (isAv1 ? " -c:v av1" : string.Empty);
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- // cuvid decoder doesn't have threading issue.
|
|
|
|
- return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // cuvid decoder doesn't have threading issue.
|
|
|
|
+ return " -hwaccel cuda" + (outputHwSurface ? " -hwaccel_output_format cuda" : string.Empty);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -5439,7 +5438,8 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|
// Automatically set thread count
|
|
// Automatically set thread count
|
|
return mustSetThreadCount ? Math.Max(Environment.ProcessorCount - 1, 1) : 0;
|
|
return mustSetThreadCount ? Math.Max(Environment.ProcessorCount - 1, 1) : 0;
|
|
}
|
|
}
|
|
- else if (threads >= Environment.ProcessorCount)
|
|
|
|
|
|
+
|
|
|
|
+ if (threads >= Environment.ProcessorCount)
|
|
{
|
|
{
|
|
return Environment.ProcessorCount;
|
|
return Environment.ProcessorCount;
|
|
}
|
|
}
|