better documentation

pull/1296/head
Felix Ableitner 2018-10-09 18:22:35 -05:00 committed by Chocobozzz
parent 7f196c9320
commit e243c38c35
1 changed files with 5 additions and 3 deletions

View File

@ -49,14 +49,16 @@ export function getTargetBitrate (resolution: VideoResolution, fps: number,
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:
// 2600 / 1750 = 1.48571428571
// 4400 / 3300 = 1.33333333333
// 720p: 2600 / 1750 = 1.48571428571
// 1080p: 4400 / 3300 = 1.33333333333
const maxBitrate = baseBitrate * 1.4
const maxBitrateDifference = maxBitrate - baseBitrate
const maxFpsDifference = fpsTranscodingConstants.MAX - fpsTranscodingConstants.AVERAGE
// For 1080p video with default settings, this results in the following formula:
// 3300 + (x - 30) * (1320/30)
// Example outputs: 1080p30: 3300 kbps, 1080p60: 4620 kbps, 720p30: 1750, 720p60: 2450
// Example outputs:
// 1080p10: 2420 kbps, 1080p30: 3300 kbps, 1080p60: 4620 kbps
// 720p10: 1283 kbps, 720p30: 1750 kbps, 720p60: 2450
return baseBitrate + (fps - fpsTranscodingConstants.AVERAGE) * (maxBitrateDifference / maxFpsDifference)
}