mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-12-01 12:59:15 -06:00
More robust max bitrate calculation
This commit is contained in:
parent
8eb07b0130
commit
49919ca16b
@ -546,7 +546,10 @@ async function prepareNotificationsTest (serversCount = 3) {
|
||||
const servers = await flushAndRunMultipleServers(serversCount, overrideConfig)
|
||||
|
||||
await setAccessTokensToServers(servers)
|
||||
await doubleFollow(servers[0], servers[1])
|
||||
|
||||
if (serversCount > 1) {
|
||||
await doubleFollow(servers[0], servers[1])
|
||||
}
|
||||
|
||||
const user = {
|
||||
username: 'user_1',
|
||||
|
@ -17,42 +17,45 @@ export enum VideoResolution {
|
||||
* Google Live Encoder: https://support.google.com/youtube/answer/2853702?hl=en
|
||||
* YouTube Video Info: youtube-dl --list-formats, with sample videos
|
||||
*/
|
||||
function getBaseBitrate (resolution: VideoResolution) {
|
||||
switch (resolution) {
|
||||
case VideoResolution.H_NOVIDEO:
|
||||
// audio-only
|
||||
return 64 * 1000
|
||||
|
||||
case VideoResolution.H_240P:
|
||||
// quality according to Google Live Encoder: 300 - 700 Kbps
|
||||
// Quality according to YouTube Video Info: 285 Kbps
|
||||
return 320 * 1000
|
||||
|
||||
case VideoResolution.H_360P:
|
||||
// quality according to Google Live Encoder: 400 - 1,000 Kbps
|
||||
// Quality according to YouTube Video Info: 700 Kbps
|
||||
return 780 * 1000
|
||||
|
||||
case VideoResolution.H_480P:
|
||||
// quality according to Google Live Encoder: 500 - 2,000 Kbps
|
||||
// Quality according to YouTube Video Info: 1300 Kbps
|
||||
return 1500 * 1000
|
||||
|
||||
case VideoResolution.H_720P:
|
||||
// quality according to Google Live Encoder: 1,500 - 4,000 Kbps
|
||||
// Quality according to YouTube Video Info: 2680 Kbps
|
||||
return 2800 * 1000
|
||||
|
||||
case VideoResolution.H_1080P:
|
||||
// quality according to Google Live Encoder: 3000 - 6000 Kbps
|
||||
// Quality according to YouTube Video Info: 5081 Kbps
|
||||
return 5200 * 1000
|
||||
|
||||
case VideoResolution.H_4K: // fallthrough
|
||||
default:
|
||||
// quality according to Google Live Encoder: 13000 - 34000 Kbps
|
||||
return 22000 * 1000
|
||||
function getBaseBitrate (resolution: number) {
|
||||
if (resolution === VideoResolution.H_NOVIDEO) {
|
||||
// audio-only
|
||||
return 64 * 1000
|
||||
}
|
||||
|
||||
if (resolution <= VideoResolution.H_240P) {
|
||||
// quality according to Google Live Encoder: 300 - 700 Kbps
|
||||
// Quality according to YouTube Video Info: 285 Kbps
|
||||
return 320 * 1000
|
||||
}
|
||||
|
||||
if (resolution <= VideoResolution.H_360P) {
|
||||
// quality according to Google Live Encoder: 400 - 1,000 Kbps
|
||||
// Quality according to YouTube Video Info: 700 Kbps
|
||||
return 780 * 1000
|
||||
}
|
||||
|
||||
if (resolution <= VideoResolution.H_480P) {
|
||||
// quality according to Google Live Encoder: 500 - 2,000 Kbps
|
||||
// Quality according to YouTube Video Info: 1300 Kbps
|
||||
return 1500 * 1000
|
||||
}
|
||||
|
||||
if (resolution <= VideoResolution.H_720P) {
|
||||
// quality according to Google Live Encoder: 1,500 - 4,000 Kbps
|
||||
// Quality according to YouTube Video Info: 2680 Kbps
|
||||
return 2800 * 1000
|
||||
}
|
||||
|
||||
if (resolution <= VideoResolution.H_1080P) {
|
||||
// quality according to Google Live Encoder: 3000 - 6000 Kbps
|
||||
// Quality according to YouTube Video Info: 5081 Kbps
|
||||
return 5200 * 1000
|
||||
}
|
||||
|
||||
// 4K
|
||||
// quality according to Google Live Encoder: 13000 - 34000 Kbps
|
||||
return 22000 * 1000
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +67,7 @@ function getBaseBitrate (resolution: VideoResolution) {
|
||||
* getBaseBitrate() * 1.4. All other values are calculated linearly
|
||||
* between these two points.
|
||||
*/
|
||||
export function getTargetBitrate (resolution: VideoResolution, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) {
|
||||
export function getTargetBitrate (resolution: number, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) {
|
||||
const baseBitrate = getBaseBitrate(resolution)
|
||||
// The maximum bitrate, used when fps === VideoTranscodingFPS.MAX
|
||||
// Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate:
|
||||
|
Loading…
Reference in New Issue
Block a user