Backport pull request #11675 from jellyfin/release-10.9.z

Fix quality parameter for vaapi_mjpeg

Original-merge: ddd5c302b4

Merged-by: nielsvanvelzen <nielsvanvelzen@users.noreply.github.com>

Backported-by: Joshua M. Boniface <joshua@boniface.me>
pull/11711/head
gnattu 6 months ago committed by Joshua M. Boniface
parent 8b938e2696
commit 7336427ce6

@ -871,6 +871,15 @@ namespace MediaBrowser.MediaEncoding.Encoder
throw new InvalidOperationException("Empty or invalid input argument.");
}
float? encoderQuality = qualityScale;
if (vidEncoder.Contains("vaapi", StringComparison.OrdinalIgnoreCase))
{
// 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);

Loading…
Cancel
Save