mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Fix the bitrate scale factor for h264-to-hevc transcoding (#9485)
This commit is contained in:
parent
6821a2ab35
commit
173a963dbf
@ -2021,14 +2021,20 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
|
|
||||||
private static double GetVideoBitrateScaleFactor(string codec)
|
private static double GetVideoBitrateScaleFactor(string codec)
|
||||||
{
|
{
|
||||||
|
// hevc & vp9 - 40% more efficient than h.264
|
||||||
if (string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
|
if (string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
|
||||||
|| string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase)
|
|| string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase)
|
||||||
|| string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase)
|
|| string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase))
|
||||||
|| string.Equals(codec, "av1", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
return .6;
|
return .6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// av1 - 50% more efficient than h.264
|
||||||
|
if (string.Equals(codec, "av1", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return .5;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2036,7 +2042,9 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
{
|
{
|
||||||
var inputScaleFactor = GetVideoBitrateScaleFactor(inputVideoCodec);
|
var inputScaleFactor = GetVideoBitrateScaleFactor(inputVideoCodec);
|
||||||
var outputScaleFactor = GetVideoBitrateScaleFactor(outputVideoCodec);
|
var outputScaleFactor = GetVideoBitrateScaleFactor(outputVideoCodec);
|
||||||
var scaleFactor = outputScaleFactor / inputScaleFactor;
|
|
||||||
|
// Don't scale the real bitrate lower than the requested bitrate
|
||||||
|
var scaleFactor = Math.Min(outputScaleFactor / inputScaleFactor, 1);
|
||||||
|
|
||||||
if (bitrate <= 500000)
|
if (bitrate <= 500000)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user