@ -557,7 +557,8 @@ namespace MediaBrowser.Controller.MediaEncoding
{
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 ) ) ;
}
@ -1109,20 +1110,20 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return "-bsf:v h264_mp4toannexb" ;
}
else if ( IsH265 ( stream ) )
if ( IsH265 ( stream ) )
{
return "-bsf:v hevc_mp4toannexb" ;
}
else if ( IsAAC ( stream ) )
if ( IsAAC ( stream ) )
{
// Convert adts header(mpegts) to asc header(mp4).
return "-bsf:a aac_adtstoasc" ;
}
else
{
return null ;
}
}
public static string GetAudioBitStreamArguments ( EncodingJobInfo state , string segmentContainer , string mediaSourceContainer )
{
@ -1199,11 +1200,9 @@ namespace MediaBrowser.Controller.MediaEncoding
{
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 ( $" -b:v {bitrate} -maxrate {bitrate} -bufsize {bufsize}" ) ;
}
@ -2762,14 +2761,13 @@ namespace MediaBrowser.Controller.MediaEncoding
widthParam ,
heightParam ) ;
}
else
{
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
else if ( requestedMaxWidth . HasValue & & requestedMaxHeight . HasValue )
if ( requestedMaxWidth . HasValue & & requestedMaxHeight . HasValue )
{
var maxWidthParam = requestedMaxWidth . Value . ToString ( CultureInfo . InvariantCulture ) ;
var maxHeightParam = requestedMaxHeight . Value . ToString ( CultureInfo . InvariantCulture ) ;
@ -2783,15 +2781,14 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// If a fixed width was requested
else if ( requestedWidth . HasValue )
if ( requestedWidth . HasValue )
{
if ( threedFormat . HasValue )
{
// This method can handle 0 being passed in for the requested height
return GetFixedSwScaleFilter ( threedFormat , requestedWidth . Value , 0 ) ;
}
else
{
var widthParam = requestedWidth . Value . ToString ( CultureInfo . InvariantCulture ) ;
return string . Format (
@ -2799,10 +2796,9 @@ namespace MediaBrowser.Controller.MediaEncoding
"scale={0}:trunc(ow/a/2)*2" ,
widthParam ) ;
}
}
// If a fixed height was requested
else if ( requestedHeight . HasValue )
if ( requestedHeight . HasValue )
{
var heightParam = requestedHeight . Value . ToString ( CultureInfo . InvariantCulture ) ;
@ -2814,7 +2810,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// If a max width was requested
else if ( requestedMaxWidth . HasValue )
if ( requestedMaxWidth . HasValue )
{
var maxWidthParam = requestedMaxWidth . Value . ToString ( CultureInfo . InvariantCulture ) ;
@ -2826,7 +2822,7 @@ namespace MediaBrowser.Controller.MediaEncoding
}
// If a max height was requested
else if ( requestedMaxHeight . HasValue )
if ( requestedMaxHeight . HasValue )
{
var maxHeightParam = requestedMaxHeight . Value . ToString ( CultureInfo . InvariantCulture ) ;
@ -2908,18 +2904,21 @@ namespace MediaBrowser.Controller.MediaEncoding
"yadif_cuda={0}:-1:0" ,
doubleRateDeint ? "1" : "0" ) ;
}
else if ( hwDeintSuffix . Contains ( "vaapi" , StringComparison . OrdinalIgnoreCase ) )
if ( hwDeintSuffix . Contains ( "vaapi" , StringComparison . OrdinalIgnoreCase ) )
{
return string . Format (
CultureInfo . InvariantCulture ,
"deinterlace_vaapi=rate={0}" ,
doubleRateDeint ? "field" : "frame" ) ;
}
else if ( hwDeintSuffix . Contains ( "qsv" , StringComparison . OrdinalIgnoreCase ) )
if ( hwDeintSuffix . Contains ( "qsv" , StringComparison . OrdinalIgnoreCase ) )
{
return "deinterlace_qsv=mode=2" ;
}
else if ( hwDeintSuffix . Contains ( "videotoolbox" , StringComparison . OrdinalIgnoreCase ) )
if ( hwDeintSuffix . Contains ( "videotoolbox" , StringComparison . OrdinalIgnoreCase ) )
{
return string . Format (
CultureInfo . InvariantCulture ,
@ -2950,7 +2949,8 @@ namespace MediaBrowser.Controller.MediaEncoding
options . VppTonemappingBrightness ,
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" ;
@ -4826,27 +4826,28 @@ namespace MediaBrowser.Controller.MediaEncoding
{
return videoStream . BitDepth . Value ;
}
else if ( string . Equals ( videoStream . PixelFormat , "yuv420p" , 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 ;
}
else if ( string . Equals ( videoStream . PixelFormat , "yuv420p10le" , StringComparison . OrdinalIgnoreCase )
if ( string . Equals ( videoStream . PixelFormat , "yuv420p10le" , StringComparison . OrdinalIgnoreCase )
| | string . Equals ( videoStream . PixelFormat , "yuv444p10le" , StringComparison . OrdinalIgnoreCase ) )
{
return 10 ;
}
else if ( string . Equals ( videoStream . PixelFormat , "yuv420p12le" , StringComparison . OrdinalIgnoreCase )
if ( string . Equals ( videoStream . PixelFormat , "yuv420p12le" , StringComparison . OrdinalIgnoreCase )
| | string . Equals ( videoStream . PixelFormat , "yuv444p12le" , StringComparison . OrdinalIgnoreCase ) )
{
return 12 ;
}
else
{
return 8 ;
}
}
return 0 ;
}
@ -5077,13 +5078,11 @@ namespace MediaBrowser.Controller.MediaEncoding
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 ) ;
}
else
{
// cuvid decoder doesn't have threading issue.
return " -hwaccel cuda" + ( outputHwSurface ? " -hwaccel_output_format cuda" : string . Empty ) ;
}
}
}
// Amd d3d11va
if ( string . Equals ( options . HardwareAccelerationType , "amf" , StringComparison . OrdinalIgnoreCase ) )
@ -5439,7 +5438,8 @@ namespace MediaBrowser.Controller.MediaEncoding
// Automatically set thread count
return mustSetThreadCount ? Math . Max ( Environment . ProcessorCount - 1 , 1 ) : 0 ;
}
else if ( threads > = Environment . ProcessorCount )
if ( threads > = Environment . ProcessorCount )
{
return Environment . ProcessorCount ;
}