aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/models/blocklist/account-block.model.ts7
-rw-r--r--shared/models/blocklist/index.ts2
-rw-r--r--shared/models/blocklist/server-block.model.ts9
-rw-r--r--shared/models/index.ts1
-rw-r--r--shared/models/users/user-right.enum.ts3
-rw-r--r--shared/models/users/user-role.ts4
-rw-r--r--shared/models/videos/video-resolution.enum.ts45
7 files changed, 55 insertions, 16 deletions
diff --git a/shared/models/blocklist/account-block.model.ts b/shared/models/blocklist/account-block.model.ts
new file mode 100644
index 000000000..a942ed614
--- /dev/null
+++ b/shared/models/blocklist/account-block.model.ts
@@ -0,0 +1,7 @@
1import { Account } from '../actors'
2
3export interface AccountBlock {
4 byAccount: Account
5 blockedAccount: Account
6 createdAt: Date | string
7}
diff --git a/shared/models/blocklist/index.ts b/shared/models/blocklist/index.ts
new file mode 100644
index 000000000..fc7873270
--- /dev/null
+++ b/shared/models/blocklist/index.ts
@@ -0,0 +1,2 @@
1export * from './account-block.model'
2export * from './server-block.model'
diff --git a/shared/models/blocklist/server-block.model.ts b/shared/models/blocklist/server-block.model.ts
new file mode 100644
index 000000000..a8b8af0b7
--- /dev/null
+++ b/shared/models/blocklist/server-block.model.ts
@@ -0,0 +1,9 @@
1import { Account } from '../actors'
2
3export interface ServerBlock {
4 byAccount: Account
5 blockedServer: {
6 host: string
7 }
8 createdAt: Date | string
9}
diff --git a/shared/models/index.ts b/shared/models/index.ts
index e61d6cbdc..062533834 100644
--- a/shared/models/index.ts
+++ b/shared/models/index.ts
@@ -1,6 +1,7 @@
1export * from './activitypub' 1export * from './activitypub'
2export * from './actors' 2export * from './actors'
3export * from './avatars' 3export * from './avatars'
4export * from './blocklist'
4export * from './redundancy' 5export * from './redundancy'
5export * from './users' 6export * from './users'
6export * from './videos' 7export * from './videos'
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts
index ed2c536ce..51c59d20a 100644
--- a/shared/models/users/user-right.enum.ts
+++ b/shared/models/users/user-right.enum.ts
@@ -8,6 +8,9 @@ export enum UserRight {
8 MANAGE_JOBS, 8 MANAGE_JOBS,
9 MANAGE_CONFIGURATION, 9 MANAGE_CONFIGURATION,
10 10
11 MANAGE_ACCOUNTS_BLOCKLIST,
12 MANAGE_SERVERS_BLOCKLIST,
13
11 MANAGE_VIDEO_BLACKLIST, 14 MANAGE_VIDEO_BLACKLIST,
12 15
13 REMOVE_ANY_VIDEO, 16 REMOVE_ANY_VIDEO,
diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts
index d7020c0f2..adef8fd95 100644
--- a/shared/models/users/user-role.ts
+++ b/shared/models/users/user-role.ts
@@ -27,7 +27,9 @@ const userRoleRights: { [ id: number ]: UserRight[] } = {
27 UserRight.REMOVE_ANY_VIDEO_CHANNEL, 27 UserRight.REMOVE_ANY_VIDEO_CHANNEL,
28 UserRight.REMOVE_ANY_VIDEO_COMMENT, 28 UserRight.REMOVE_ANY_VIDEO_COMMENT,
29 UserRight.UPDATE_ANY_VIDEO, 29 UserRight.UPDATE_ANY_VIDEO,
30 UserRight.SEE_ALL_VIDEOS 30 UserRight.SEE_ALL_VIDEOS,
31 UserRight.MANAGE_ACCOUNTS_BLOCKLIST,
32 UserRight.MANAGE_SERVERS_BLOCKLIST
31 ], 33 ],
32 34
33 [UserRole.USER]: [] 35 [UserRole.USER]: []
diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts
index e40e5b58b..2eee03843 100644
--- a/shared/models/videos/video-resolution.enum.ts
+++ b/shared/models/videos/video-resolution.enum.ts
@@ -9,13 +9,13 @@ export enum VideoResolution {
9} 9}
10 10
11/** 11/**
12 * Bitrate targets for different resolutions and frame rates, in bytes per second. 12 * Bitrate targets for different resolutions, at VideoTranscodingFPS.AVERAGE.
13 *
13 * Sources for individual quality levels: 14 * Sources for individual quality levels:
14 * Google Live Encoder: https://support.google.com/youtube/answer/2853702?hl=en 15 * Google Live Encoder: https://support.google.com/youtube/answer/2853702?hl=en
15 * YouTube Video Info (tested with random music video): https://www.h3xed.com/blogmedia/youtube-info.php 16 * YouTube Video Info (tested with random music video): https://www.h3xed.com/blogmedia/youtube-info.php
16 */ 17 */
17export function getTargetBitrate (resolution: VideoResolution, fps: number, 18function getBaseBitrate (resolution: VideoResolution) {
18 fpsTranscodingConstants: VideoTranscodingFPS) {
19 switch (resolution) { 19 switch (resolution) {
20 case VideoResolution.H_240P: 20 case VideoResolution.H_240P:
21 // quality according to Google Live Encoder: 300 - 700 Kbps 21 // quality according to Google Live Encoder: 300 - 700 Kbps
@@ -30,23 +30,11 @@ export function getTargetBitrate (resolution: VideoResolution, fps: number,
30 // Quality according to YouTube Video Info: 879 Kbps 30 // Quality according to YouTube Video Info: 879 Kbps
31 return 900 * 1000 31 return 900 * 1000
32 case VideoResolution.H_720P: 32 case VideoResolution.H_720P:
33 if (fps === fpsTranscodingConstants.MAX) {
34 // quality according to Google Live Encoder: 2,250 - 6,000 Kbps
35 // Quality according to YouTube Video Info: 2634 Kbps
36 return 2600 * 1000
37 }
38
39 // quality according to Google Live Encoder: 1,500 - 4,000 Kbps 33 // quality according to Google Live Encoder: 1,500 - 4,000 Kbps
40 // Quality according to YouTube Video Info: 1752 Kbps 34 // Quality according to YouTube Video Info: 1752 Kbps
41 return 1750 * 1000 35 return 1750 * 1000
42 case VideoResolution.H_1080P: // fallthrough 36 case VideoResolution.H_1080P: // fallthrough
43 default: 37 default:
44 if (fps === fpsTranscodingConstants.MAX) {
45 // quality according to Google Live Encoder: 3000 - 6000 Kbps
46 // Quality according to YouTube Video Info: 4387 Kbps
47 return 4400 * 1000
48 }
49
50 // quality according to Google Live Encoder: 3000 - 6000 Kbps 38 // quality according to Google Live Encoder: 3000 - 6000 Kbps
51 // Quality according to YouTube Video Info: 3277 Kbps 39 // Quality according to YouTube Video Info: 3277 Kbps
52 return 3300 * 1000 40 return 3300 * 1000
@@ -54,6 +42,33 @@ export function getTargetBitrate (resolution: VideoResolution, fps: number,
54} 42}
55 43
56/** 44/**
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.
52 */
53export function getTargetBitrate (resolution: VideoResolution, fps: number,
54 fpsTranscodingConstants: VideoTranscodingFPS) {
55 const baseBitrate = getBaseBitrate(resolution)
56 // The maximum bitrate, used when fps === VideoTranscodingFPS.MAX
57 // Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate:
58 // 720p: 2600 / 1750 = 1.49
59 // 1080p: 4400 / 3300 = 1.33
60 const maxBitrate = baseBitrate * 1.4
61 const maxBitrateDifference = maxBitrate - baseBitrate
62 const maxFpsDifference = fpsTranscodingConstants.MAX - fpsTranscodingConstants.AVERAGE
63 // For 1080p video with default settings, this results in the following formula:
64 // 3300 + (x - 30) * (1320/30)
65 // Example outputs:
66 // 1080p10: 2420 kbps, 1080p30: 3300 kbps, 1080p60: 4620 kbps
67 // 720p10: 1283 kbps, 720p30: 1750 kbps, 720p60: 2450 kbps
68 return baseBitrate + (fps - fpsTranscodingConstants.AVERAGE) * (maxBitrateDifference / maxFpsDifference)
69}
70
71/**
57 * The maximum bitrate we expect to see on a transcoded video in bytes per second. 72 * The maximum bitrate we expect to see on a transcoded video in bytes per second.
58 */ 73 */
59export function getMaxBitrate (resolution: VideoResolution, fps: number, 74export function getMaxBitrate (resolution: VideoResolution, fps: number,