diff options
Diffstat (limited to 'shared/models')
-rw-r--r-- | shared/models/actors/account.model.ts | 2 | ||||
-rw-r--r-- | shared/models/search/videos-search-query.model.ts | 3 | ||||
-rw-r--r-- | shared/models/users/index.ts | 1 | ||||
-rw-r--r-- | shared/models/users/user-right.enum.ts | 1 | ||||
-rw-r--r-- | shared/models/users/user-role.ts | 3 | ||||
-rw-r--r-- | shared/models/users/user-watching-video.model.ts | 3 | ||||
-rw-r--r-- | shared/models/videos/index.ts | 1 | ||||
-rw-r--r-- | shared/models/videos/video-query.type.ts | 2 | ||||
-rw-r--r-- | shared/models/videos/video-resolution.enum.ts | 55 | ||||
-rw-r--r-- | shared/models/videos/video-transcoding-fps.model.ts | 6 | ||||
-rw-r--r-- | shared/models/videos/video.model.ts | 4 |
11 files changed, 79 insertions, 2 deletions
diff --git a/shared/models/actors/account.model.ts b/shared/models/actors/account.model.ts index e1117486d..7f1dbbc37 100644 --- a/shared/models/actors/account.model.ts +++ b/shared/models/actors/account.model.ts | |||
@@ -3,4 +3,6 @@ import { Actor } from './actor.model' | |||
3 | export interface Account extends Actor { | 3 | export interface Account extends Actor { |
4 | displayName: string | 4 | displayName: string |
5 | description: string | 5 | description: string |
6 | |||
7 | userId?: number | ||
6 | } | 8 | } |
diff --git a/shared/models/search/videos-search-query.model.ts b/shared/models/search/videos-search-query.model.ts index 29aa5c100..0db220758 100644 --- a/shared/models/search/videos-search-query.model.ts +++ b/shared/models/search/videos-search-query.model.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { NSFWQuery } from './nsfw-query.model' | 1 | import { NSFWQuery } from './nsfw-query.model' |
2 | import { VideoFilter } from '../videos' | ||
2 | 3 | ||
3 | export interface VideosSearchQuery { | 4 | export interface VideosSearchQuery { |
4 | search?: string | 5 | search?: string |
@@ -23,4 +24,6 @@ export interface VideosSearchQuery { | |||
23 | 24 | ||
24 | durationMin?: number // seconds | 25 | durationMin?: number // seconds |
25 | durationMax?: number // seconds | 26 | durationMax?: number // seconds |
27 | |||
28 | filter?: VideoFilter | ||
26 | } | 29 | } |
diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts index 15c2f99c2..7114741e0 100644 --- a/shared/models/users/index.ts +++ b/shared/models/users/index.ts | |||
@@ -7,3 +7,4 @@ export * from './user-update-me.model' | |||
7 | export * from './user-right.enum' | 7 | export * from './user-right.enum' |
8 | export * from './user-role' | 8 | export * from './user-role' |
9 | export * from './user-video-quota.model' | 9 | export * from './user-video-quota.model' |
10 | export * from './user-watching-video.model' | ||
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts index c4ccd632f..ed2c536ce 100644 --- a/shared/models/users/user-right.enum.ts +++ b/shared/models/users/user-right.enum.ts | |||
@@ -14,5 +14,6 @@ export enum UserRight { | |||
14 | REMOVE_ANY_VIDEO_CHANNEL, | 14 | REMOVE_ANY_VIDEO_CHANNEL, |
15 | REMOVE_ANY_VIDEO_COMMENT, | 15 | REMOVE_ANY_VIDEO_COMMENT, |
16 | UPDATE_ANY_VIDEO, | 16 | UPDATE_ANY_VIDEO, |
17 | SEE_ALL_VIDEOS, | ||
17 | CHANGE_VIDEO_OWNERSHIP | 18 | CHANGE_VIDEO_OWNERSHIP |
18 | } | 19 | } |
diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index 552aad999..d7020c0f2 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts | |||
@@ -26,7 +26,8 @@ const userRoleRights: { [ id: number ]: UserRight[] } = { | |||
26 | UserRight.REMOVE_ANY_VIDEO, | 26 | UserRight.REMOVE_ANY_VIDEO, |
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 | ], | 31 | ], |
31 | 32 | ||
32 | [UserRole.USER]: [] | 33 | [UserRole.USER]: [] |
diff --git a/shared/models/users/user-watching-video.model.ts b/shared/models/users/user-watching-video.model.ts new file mode 100644 index 000000000..c22480595 --- /dev/null +++ b/shared/models/users/user-watching-video.model.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export interface UserWatchingVideo { | ||
2 | currentTime: number | ||
3 | } | ||
diff --git a/shared/models/videos/index.ts b/shared/models/videos/index.ts index 90a0e3053..056ae06da 100644 --- a/shared/models/videos/index.ts +++ b/shared/models/videos/index.ts | |||
@@ -21,6 +21,7 @@ export * from './video-update.model' | |||
21 | export * from './video.model' | 21 | export * from './video.model' |
22 | export * from './video-query.type' | 22 | export * from './video-query.type' |
23 | export * from './video-state.enum' | 23 | export * from './video-state.enum' |
24 | export * from './video-transcoding-fps.model' | ||
24 | export * from './caption/video-caption.model' | 25 | export * from './caption/video-caption.model' |
25 | export * from './caption/video-caption-update.model' | 26 | export * from './caption/video-caption-update.model' |
26 | export * from './import/video-import-create.model' | 27 | export * from './import/video-import-create.model' |
diff --git a/shared/models/videos/video-query.type.ts b/shared/models/videos/video-query.type.ts index ff0f527f3..f76a91aad 100644 --- a/shared/models/videos/video-query.type.ts +++ b/shared/models/videos/video-query.type.ts | |||
@@ -1 +1 @@ | |||
export type VideoFilter = 'local' | export type VideoFilter = 'local' | 'all-local' | ||
diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts index 100fc0e6e..e40e5b58b 100644 --- a/shared/models/videos/video-resolution.enum.ts +++ b/shared/models/videos/video-resolution.enum.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import { VideoTranscodingFPS } from './video-transcoding-fps.model' | ||
2 | |||
1 | export enum VideoResolution { | 3 | export enum VideoResolution { |
2 | H_240P = 240, | 4 | H_240P = 240, |
3 | H_360P = 360, | 5 | H_360P = 360, |
@@ -5,3 +7,56 @@ export enum VideoResolution { | |||
5 | H_720P = 720, | 7 | H_720P = 720, |
6 | H_1080P = 1080 | 8 | H_1080P = 1080 |
7 | } | 9 | } |
10 | |||
11 | /** | ||
12 | * Bitrate targets for different resolutions and frame rates, in bytes per second. | ||
13 | * Sources for individual quality levels: | ||
14 | * 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 | */ | ||
17 | export function getTargetBitrate (resolution: VideoResolution, fps: number, | ||
18 | fpsTranscodingConstants: VideoTranscodingFPS) { | ||
19 | switch (resolution) { | ||
20 | case VideoResolution.H_240P: | ||
21 | // quality according to Google Live Encoder: 300 - 700 Kbps | ||
22 | // Quality according to YouTube Video Info: 186 Kbps | ||
23 | return 250 * 1000 | ||
24 | case VideoResolution.H_360P: | ||
25 | // quality according to Google Live Encoder: 400 - 1,000 Kbps | ||
26 | // Quality according to YouTube Video Info: 480 Kbps | ||
27 | return 500 * 1000 | ||
28 | case VideoResolution.H_480P: | ||
29 | // quality according to Google Live Encoder: 500 - 2,000 Kbps | ||
30 | // Quality according to YouTube Video Info: 879 Kbps | ||
31 | return 900 * 1000 | ||
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 | ||
40 | // Quality according to YouTube Video Info: 1752 Kbps | ||
41 | return 1750 * 1000 | ||
42 | case VideoResolution.H_1080P: // fallthrough | ||
43 | 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 | ||
51 | // Quality according to YouTube Video Info: 3277 Kbps | ||
52 | return 3300 * 1000 | ||
53 | } | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * The maximum bitrate we expect to see on a transcoded video in bytes per second. | ||
58 | */ | ||
59 | export function getMaxBitrate (resolution: VideoResolution, fps: number, | ||
60 | fpsTranscodingConstants: VideoTranscodingFPS) { | ||
61 | return getTargetBitrate(resolution, fps, fpsTranscodingConstants) * 2 | ||
62 | } | ||
diff --git a/shared/models/videos/video-transcoding-fps.model.ts b/shared/models/videos/video-transcoding-fps.model.ts new file mode 100644 index 000000000..82022d2f1 --- /dev/null +++ b/shared/models/videos/video-transcoding-fps.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export type VideoTranscodingFPS = { | ||
2 | MIN: number, | ||
3 | AVERAGE: number, | ||
4 | MAX: number, | ||
5 | KEEP_ORIGIN_FPS_RESOLUTION_MIN: number | ||
6 | } | ||
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index b47ab1ab8..4a9fa58b1 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts | |||
@@ -68,6 +68,10 @@ export interface Video { | |||
68 | 68 | ||
69 | account: AccountAttribute | 69 | account: AccountAttribute |
70 | channel: VideoChannelAttribute | 70 | channel: VideoChannelAttribute |
71 | |||
72 | userHistory?: { | ||
73 | currentTime: number | ||
74 | } | ||
71 | } | 75 | } |
72 | 76 | ||
73 | export interface VideoDetails extends Video { | 77 | export interface VideoDetails extends Video { |