@ -871,6 +871,15 @@ namespace MediaBrowser.MediaEncoding.Encoder
throw new InvalidOperationException ( "Empty or invalid input argument." ) ;
}
float? encoderQuality = qualityScale ;
if ( vidEncoder . Contains ( "vaapi" , StringComparison . InvariantCultureIgnoreCase ) )
{
// vaapi's mjpeg encoder uses jpeg quality divided by QP2LAMBDA (118) as input, instead of ffmpeg defined qscale
// ffmpeg qscale is a value from 1-31, with 1 being best quality and 31 being worst
// jpeg quality is a value from 0-100, with 0 being worst quality and 100 being best
encoderQuality = ( 100 - ( ( qualityScale - 1 ) * ( 100 / 30 ) ) ) / 118 ;
}
// Output arguments
var targetDirectory = Path . Combine ( _configurationManager . ApplicationPaths . TempDirectory , Guid . NewGuid ( ) . ToString ( "N" ) ) ;
Directory . CreateDirectory ( targetDirectory ) ;
@ -884,7 +893,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
filterParam ,
outputThreads . GetValueOrDefault ( _threads ) ,
vidEncoder ,
qualityScale . HasValue ? "-qscale:v " + qualityScale . Value . ToString ( CultureInfo . InvariantCulture ) + " " : string . Empty ,
qualityScale . HasValue ? "-qscale:v " + encoderQuality . Value . ToString ( CultureInfo . InvariantCulture ) + " " : string . Empty ,
"image2" ,
outputPath ) ;