@ -317,34 +317,9 @@ namespace MediaBrowser.MediaEncoding.Encoder
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
if ( job . ReadInputAtNativeFramerate )
{
if ( isWebm )
{
return Math . Max ( Environment . ProcessorCount - 1 , 2 ) ;
}
return 0 ;
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 EncodingQuality GetQualitySetting ( )
protected EncodingQuality GetQualitySetting ( )
{
{
var quality = GetEncodingOptions ( ) . EncodingQuality ;
var quality = GetEncodingOptions ( ) . EncodingQuality ;
@ -650,29 +625,36 @@ namespace MediaBrowser.MediaEncoding.Encoder
if ( string . Equals ( videoCodec , "libx264" , 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 ;
}
}
}
}