@ -279,32 +279,7 @@ namespace MediaBrowser.Api.Playback
return Math . Max ( Environment . ProcessorCount - 1 , 2 ) ;
return Math . Max ( Environment . ProcessorCount - 1 , 2 ) ;
}
}
// Use more when this is true. -re will keep cpu usage under control
return 0 ;
if ( state . ReadInputAtNativeFramerate )
{
if ( isWebm )
{
return Math . Max ( Environment . ProcessorCount - 1 , 2 ) ;
}
return 0 ;
}
// Webm: http://www.webmproject.org/docs/encoder-parameters/
// The decoder will usually automatically use an appropriate number of threads according to how many cores are available but it can only use multiple threads
// for the coefficient data if the encoder selected --token-parts > 0 at encode time.
switch ( GetQualitySetting ( ) )
{
case EncodingQuality . HighSpeed :
return 2 ;
case EncodingQuality . HighQuality :
return 2 ;
case EncodingQuality . MaxQuality :
return isWebm ? Math . Max ( Environment . ProcessorCount - 1 , 2 ) : 0 ;
default :
throw new Exception ( "Unrecognized MediaEncodingQuality value." ) ;
}
}
}
protected string H264Encoder
protected string H264Encoder
@ -338,31 +313,38 @@ namespace MediaBrowser.Api.Playback
var qualitySetting = GetQualitySetting ( ) ;
var qualitySetting = GetQualitySetting ( ) ;
if ( string . Equals ( videoCodec , H264Encoder , StringComparison . OrdinalIgnoreCase ) )
if ( string . Equals ( videoCodec , "libx264" , StringComparison . OrdinalIgnoreCase ) )
{
{
param = "-preset superfast" ;
switch ( qualitySetting )
switch ( qualitySetting )
{
{
case EncodingQuality . HighSpeed :
case EncodingQuality . HighSpeed :
param = "-preset superfast ";
param += " -crf 23 ";
break ;
break ;
case EncodingQuality . HighQuality :
case EncodingQuality . HighQuality :
param = "-preset superfast ";
param += " -crf 20 ";
break ;
break ;
case EncodingQuality . MaxQuality :
case EncodingQuality . MaxQuality :
param = "-preset superfast ";
param += " -crf 18 ";
break ;
break ;
}
}
}
else if ( string . Equals ( videoCodec , "libx265" , StringComparison . OrdinalIgnoreCase ) )
{
param = "-preset fast" ;
switch ( qualitySetting )
switch ( qualitySetting )
{
{
case EncodingQuality . HighSpeed :
case EncodingQuality . HighSpeed :
param + = " -crf 23" ;
param + = " -crf 2 8 ";
break ;
break ;
case EncodingQuality . HighQuality :
case EncodingQuality . HighQuality :
param + = " -crf 2 0 ";
param + = " -crf 2 5 ";
break ;
break ;
case EncodingQuality . MaxQuality :
case EncodingQuality . MaxQuality :
param + = " -crf 18 ";
param + = " -crf 2 1";
break ;
break ;
}
}
}
}