aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/videos/video-resolution.enum.ts
diff options
context:
space:
mode:
authorFelix Ableitner <me@nutomic.com>2018-10-09 18:53:16 -0500
committerChocobozzz <me@florianbigard.com>2018-10-17 10:05:17 +0200
commit2f71dcf8de13e5250957173c9a2efe1c5544aeb2 (patch)
treef705f42b43c6674d462ef5b050d9942ea3363465 /shared/models/videos/video-resolution.enum.ts
parente243c38c356b5cfd8ba1783f19389a99dc5cf527 (diff)
downloadPeerTube-2f71dcf8de13e5250957173c9a2efe1c5544aeb2.tar.gz
PeerTube-2f71dcf8de13e5250957173c9a2efe1c5544aeb2.tar.zst
PeerTube-2f71dcf8de13e5250957173c9a2efe1c5544aeb2.zip
more documentation
Diffstat (limited to 'shared/models/videos/video-resolution.enum.ts')
-rw-r--r--shared/models/videos/video-resolution.enum.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts
index 4d2644cc0..c9b258921 100644
--- a/shared/models/videos/video-resolution.enum.ts
+++ b/shared/models/videos/video-resolution.enum.ts
@@ -43,14 +43,20 @@ export function getBaseBitrate (resolution: VideoResolution) {
43 43
44/** 44/**
45 * Calculate the target bitrate based on video resolution and FPS. 45 * Calculate the target bitrate based on video resolution and FPS.
46 *
47 * The calculation is based on two values:
48 * Bitrate at VideoTranscodingFPS.AVERAGE is always the same as
49 * getBaseBitrate(). Bitrate at VideoTranscodingFPS.MAX is always
50 * getBaseBitrate() * 1.4. All other values are calculated linearly
51 * between these two points.
46 */ 52 */
47export function getTargetBitrate (resolution: VideoResolution, fps: number, 53export function getTargetBitrate (resolution: VideoResolution, fps: number,
48 fpsTranscodingConstants: VideoTranscodingFPS) { 54 fpsTranscodingConstants: VideoTranscodingFPS) {
49 const baseBitrate = getBaseBitrate(resolution) 55 const baseBitrate = getBaseBitrate(resolution)
50 // The maximum bitrate, used when fps === VideoTranscodingFPS.MAX 56 // The maximum bitrate, used when fps === VideoTranscodingFPS.MAX
51 // Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate: 57 // Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate:
52 // 720p: 2600 / 1750 = 1.48571428571 58 // 720p: 2600 / 1750 = 1.49
53 // 1080p: 4400 / 3300 = 1.33333333333 59 // 1080p: 4400 / 3300 = 1.33
54 const maxBitrate = baseBitrate * 1.4 60 const maxBitrate = baseBitrate * 1.4
55 const maxBitrateDifference = maxBitrate - baseBitrate 61 const maxBitrateDifference = maxBitrate - baseBitrate
56 const maxFpsDifference = fpsTranscodingConstants.MAX - fpsTranscodingConstants.AVERAGE 62 const maxFpsDifference = fpsTranscodingConstants.MAX - fpsTranscodingConstants.AVERAGE
@@ -58,7 +64,7 @@ export function getTargetBitrate (resolution: VideoResolution, fps: number,
58 // 3300 + (x - 30) * (1320/30) 64 // 3300 + (x - 30) * (1320/30)
59 // Example outputs: 65 // Example outputs:
60 // 1080p10: 2420 kbps, 1080p30: 3300 kbps, 1080p60: 4620 kbps 66 // 1080p10: 2420 kbps, 1080p30: 3300 kbps, 1080p60: 4620 kbps
61 // 720p10: 1283 kbps, 720p30: 1750 kbps, 720p60: 2450 67 // 720p10: 1283 kbps, 720p30: 1750 kbps, 720p60: 2450 kbps
62 return baseBitrate + (fps - fpsTranscodingConstants.AVERAGE) * (maxBitrateDifference / maxFpsDifference) 68 return baseBitrate + (fps - fpsTranscodingConstants.AVERAGE) * (maxBitrateDifference / maxFpsDifference)
63} 69}
64 70