aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/users/user-notifications.ts5
-rw-r--r--shared/models/videos/video-resolution.enum.ts65
2 files changed, 38 insertions, 32 deletions
diff --git a/shared/extra-utils/users/user-notifications.ts b/shared/extra-utils/users/user-notifications.ts
index 30c36a388..a17a39de9 100644
--- a/shared/extra-utils/users/user-notifications.ts
+++ b/shared/extra-utils/users/user-notifications.ts
@@ -546,7 +546,10 @@ async function prepareNotificationsTest (serversCount = 3) {
546 const servers = await flushAndRunMultipleServers(serversCount, overrideConfig) 546 const servers = await flushAndRunMultipleServers(serversCount, overrideConfig)
547 547
548 await setAccessTokensToServers(servers) 548 await setAccessTokensToServers(servers)
549 await doubleFollow(servers[0], servers[1]) 549
550 if (serversCount > 1) {
551 await doubleFollow(servers[0], servers[1])
552 }
550 553
551 const user = { 554 const user = {
552 username: 'user_1', 555 username: 'user_1',
diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts
index 06e077961..8b5a96cb6 100644
--- a/shared/models/videos/video-resolution.enum.ts
+++ b/shared/models/videos/video-resolution.enum.ts
@@ -17,42 +17,45 @@ export enum VideoResolution {
17 * Google Live Encoder: https://support.google.com/youtube/answer/2853702?hl=en 17 * Google Live Encoder: https://support.google.com/youtube/answer/2853702?hl=en
18 * YouTube Video Info: youtube-dl --list-formats, with sample videos 18 * YouTube Video Info: youtube-dl --list-formats, with sample videos
19 */ 19 */
20function getBaseBitrate (resolution: VideoResolution) { 20function getBaseBitrate (resolution: number) {
21 switch (resolution) { 21 if (resolution === VideoResolution.H_NOVIDEO) {
22 case VideoResolution.H_NOVIDEO: 22 // audio-only
23 // audio-only 23 return 64 * 1000
24 return 64 * 1000 24 }
25
26 case VideoResolution.H_240P:
27 // quality according to Google Live Encoder: 300 - 700 Kbps
28 // Quality according to YouTube Video Info: 285 Kbps
29 return 320 * 1000
30 25
31 case VideoResolution.H_360P: 26 if (resolution <= VideoResolution.H_240P) {
32 // quality according to Google Live Encoder: 400 - 1,000 Kbps 27 // quality according to Google Live Encoder: 300 - 700 Kbps
33 // Quality according to YouTube Video Info: 700 Kbps 28 // Quality according to YouTube Video Info: 285 Kbps
34 return 780 * 1000 29 return 320 * 1000
30 }
35 31
36 case VideoResolution.H_480P: 32 if (resolution <= VideoResolution.H_360P) {
37 // quality according to Google Live Encoder: 500 - 2,000 Kbps 33 // quality according to Google Live Encoder: 400 - 1,000 Kbps
38 // Quality according to YouTube Video Info: 1300 Kbps 34 // Quality according to YouTube Video Info: 700 Kbps
39 return 1500 * 1000 35 return 780 * 1000
36 }
40 37
41 case VideoResolution.H_720P: 38 if (resolution <= VideoResolution.H_480P) {
42 // quality according to Google Live Encoder: 1,500 - 4,000 Kbps 39 // quality according to Google Live Encoder: 500 - 2,000 Kbps
43 // Quality according to YouTube Video Info: 2680 Kbps 40 // Quality according to YouTube Video Info: 1300 Kbps
44 return 2800 * 1000 41 return 1500 * 1000
42 }
45 43
46 case VideoResolution.H_1080P: 44 if (resolution <= VideoResolution.H_720P) {
47 // quality according to Google Live Encoder: 3000 - 6000 Kbps 45 // quality according to Google Live Encoder: 1,500 - 4,000 Kbps
48 // Quality according to YouTube Video Info: 5081 Kbps 46 // Quality according to YouTube Video Info: 2680 Kbps
49 return 5200 * 1000 47 return 2800 * 1000
48 }
50 49
51 case VideoResolution.H_4K: // fallthrough 50 if (resolution <= VideoResolution.H_1080P) {
52 default: 51 // quality according to Google Live Encoder: 3000 - 6000 Kbps
53 // quality according to Google Live Encoder: 13000 - 34000 Kbps 52 // Quality according to YouTube Video Info: 5081 Kbps
54 return 22000 * 1000 53 return 5200 * 1000
55 } 54 }
55
56 // 4K
57 // quality according to Google Live Encoder: 13000 - 34000 Kbps
58 return 22000 * 1000
56} 59}
57 60
58/** 61/**
@@ -64,7 +67,7 @@ function getBaseBitrate (resolution: VideoResolution) {
64 * getBaseBitrate() * 1.4. All other values are calculated linearly 67 * getBaseBitrate() * 1.4. All other values are calculated linearly
65 * between these two points. 68 * between these two points.
66 */ 69 */
67export function getTargetBitrate (resolution: VideoResolution, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) { 70export function getTargetBitrate (resolution: number, fps: number, fpsTranscodingConstants: VideoTranscodingFPS) {
68 const baseBitrate = getBaseBitrate(resolution) 71 const baseBitrate = getBaseBitrate(resolution)
69 // The maximum bitrate, used when fps === VideoTranscodingFPS.MAX 72 // The maximum bitrate, used when fps === VideoTranscodingFPS.MAX
70 // Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate: 73 // Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate: