Better bitrate and resolution normalization (#12644)

This commit is contained in:
gnattu
2024-09-22 10:01:47 +08:00
committed by GitHub
parent c97c2217a5
commit 56cf1a581c
3 changed files with 51 additions and 36 deletions

View File

@@ -2400,7 +2400,7 @@ namespace MediaBrowser.Controller.MediaEncoding
return 1;
}
private static int ScaleBitrate(int bitrate, string inputVideoCodec, string outputVideoCodec)
public static int ScaleBitrate(int bitrate, string inputVideoCodec, string outputVideoCodec)
{
var inputScaleFactor = GetVideoBitrateScaleFactor(inputVideoCodec);
var outputScaleFactor = GetVideoBitrateScaleFactor(outputVideoCodec);
@@ -2424,6 +2424,12 @@ namespace MediaBrowser.Controller.MediaEncoding
{
scaleFactor = Math.Max(scaleFactor, 2);
}
else if (bitrate >= 30000000)
{
// Don't scale beyond 30Mbps, it is hardly visually noticeable for most codecs with our prefer speed encoding
// and will cause extremely high bitrate to be used for av1->h264 transcoding that will overload clients and encoders
scaleFactor = 1;
}
return Convert.ToInt32(scaleFactor * bitrate);
}