mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Increase reference bitrate for high efficiency codecs
This commit is contained in:
parent
33a5533b11
commit
020dad8867
2 changed files with 12 additions and 6 deletions
|
@ -8,15 +8,14 @@ function showQualityMenu(player, btn) {
|
|||
const videoStream = playbackManager.currentMediaSource(player).MediaStreams.filter(function (stream) {
|
||||
return stream.Type === 'Video';
|
||||
})[0];
|
||||
const videoWidth = videoStream ? videoStream.Width : null;
|
||||
const videoHeight = videoStream ? videoStream.Height : null;
|
||||
|
||||
const videoCodec = videoStream ? videoStream.Codec : null;
|
||||
const videoBitRate = videoStream ? videoStream.BitRate : null;
|
||||
|
||||
const options = qualityoptions.getVideoQualityOptions({
|
||||
currentMaxBitrate: playbackManager.getMaxStreamingBitrate(player),
|
||||
isAutomaticBitrateEnabled: playbackManager.enableAutomaticBitrateDetection(player),
|
||||
videoWidth: videoWidth,
|
||||
videoHeight: videoHeight,
|
||||
videoCodec,
|
||||
videoBitRate,
|
||||
enableAuto: true
|
||||
});
|
||||
|
|
|
@ -3,6 +3,8 @@ import globalize from '../lib/globalize';
|
|||
export function getVideoQualityOptions(options) {
|
||||
const maxStreamingBitrate = options.currentMaxBitrate;
|
||||
const videoBitRate = options.videoBitRate ?? -1;
|
||||
const videoCodec = options.videoCodec;
|
||||
let referenceBitRate = videoBitRate;
|
||||
|
||||
// Quality options are indexed by bitrate. If you must duplicate them, make sure each of them are unique (by making the last digit a 1)
|
||||
// Question: the maxHeight field seems not be used anywhere, is it safe to remove those?
|
||||
|
@ -36,13 +38,18 @@ export function getVideoQualityOptions(options) {
|
|||
}
|
||||
|
||||
if (videoBitRate > 0 && videoBitRate < bitrateConfigurations[0].bitrate) {
|
||||
// Slightly increase reference bitrate for high efficiency codecs when it is not too high
|
||||
// Ideally we only need to do this for transcoding to h264, but we need extra api request to get that info which is not ideal for this
|
||||
if (videoCodec && ['hevc', 'av1', 'vp9'].includes(videoCodec) && referenceBitRate <= 20000000) {
|
||||
referenceBitRate *= 1.5;
|
||||
}
|
||||
// Push one entry that has higher limit than video bitrate to allow using source bitrate when Auto is also limited
|
||||
const sourceOptions = bitrateConfigurations.filter((c) => c.bitrate > videoBitRate).pop();
|
||||
const sourceOptions = bitrateConfigurations.filter((c) => c.bitrate > referenceBitRate).pop();
|
||||
qualityOptions.push(sourceOptions);
|
||||
}
|
||||
|
||||
bitrateConfigurations.forEach((c) => {
|
||||
if (videoBitRate <= 0 || c.bitrate <= videoBitRate) {
|
||||
if (videoBitRate <= 0 || c.bitrate <= referenceBitRate) {
|
||||
qualityOptions.push(c);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue