From b7085c713220c9c5a96c9bb77330c2ba6ae9274e Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 24 Dec 2020 18:02:04 +0100 Subject: [PATCH] add support for 1440p (Quad HD/QHD/WQHD) videos --- .../edit-custom-config/edit-custom-config.component.ts | 4 ++++ config/default.yaml | 2 ++ config/production.yaml.example | 2 ++ config/test.yaml | 2 ++ server/controllers/api/config.ts | 2 ++ server/helpers/ffprobe-utils.ts | 1 + server/initializers/checker-before-init.ts | 5 +++-- server/initializers/config.ts | 2 ++ server/middlewares/validators/config.ts | 2 ++ server/tests/api/check-params/config.ts | 2 ++ server/tests/api/live/live-constraints.ts | 1 + server/tests/api/live/live-permanent.ts | 2 ++ server/tests/api/live/live-save-replay.ts | 1 + server/tests/api/server/config.ts | 4 ++++ server/tests/api/server/stats.ts | 1 + server/tests/api/videos/audio-only.ts | 1 + server/tests/api/videos/video-hls.ts | 1 + server/tests/cli/create-transcoding-job.ts | 1 + shared/extra-utils/server/config.ts | 2 ++ shared/models/server/custom-config.model.ts | 1 + shared/models/videos/video-resolution.enum.ts | 9 ++++++++- support/doc/api/openapi.yaml | 4 +++- .../production/config/custom-environment-variables.yaml | 3 +++ 23 files changed, 51 insertions(+), 4 deletions(-) diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index f74229af0..330ab075a 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -81,6 +81,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A id: '1080p', label: $localize`1080p` }, + { + id: '1440p', + label: $localize`1440p` + }, { id: '2160p', label: $localize`2160p` diff --git a/config/default.yaml b/config/default.yaml index b68a96f51..d2c713b52 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -227,6 +227,7 @@ transcoding: 480p: false 720p: false 1080p: false + 1440p: false 2160p: false # Generate videos in a WebTorrent format (what we do since the first PeerTube release) @@ -280,6 +281,7 @@ live: 480p: false 720p: false 1080p: false + 1440p: false 2160p: false import: diff --git a/config/production.yaml.example b/config/production.yaml.example index 91eecbd67..4506ce259 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -240,6 +240,7 @@ transcoding: 480p: false 720p: false 1080p: false + 1440p: false 2160p: false # Generate videos in a WebTorrent format (what we do since the first PeerTube release) @@ -293,6 +294,7 @@ live: 480p: false 720p: false 1080p: false + 1440p: false 2160p: false import: diff --git a/config/test.yaml b/config/test.yaml index a8a724255..3e0346d64 100644 --- a/config/test.yaml +++ b/config/test.yaml @@ -78,6 +78,7 @@ transcoding: 480p: true 720p: true 1080p: true + 1440p: true 2160p: true hls: enabled: true @@ -98,6 +99,7 @@ live: 480p: false 720p: false 1080p: false + 1440p: false 2160p: false import: diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 2401e2ff4..8bc3123bf 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -423,6 +423,7 @@ function customConfig (): CustomConfig { '480p': CONFIG.TRANSCODING.RESOLUTIONS['480p'], '720p': CONFIG.TRANSCODING.RESOLUTIONS['720p'], '1080p': CONFIG.TRANSCODING.RESOLUTIONS['1080p'], + '1440p': CONFIG.TRANSCODING.RESOLUTIONS['1440p'], '2160p': CONFIG.TRANSCODING.RESOLUTIONS['2160p'] }, webtorrent: { @@ -447,6 +448,7 @@ function customConfig (): CustomConfig { '480p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['480p'], '720p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['720p'], '1080p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['1080p'], + '1440p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['1440p'], '2160p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['2160p'] } } diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts index 4dea6283c..adb459ed3 100644 --- a/server/helpers/ffprobe-utils.ts +++ b/server/helpers/ffprobe-utils.ts @@ -188,6 +188,7 @@ function computeResolutionsToTranscode (videoFileResolution: number, type: 'vod' VideoResolution.H_720P, VideoResolution.H_240P, VideoResolution.H_1080P, + VideoResolution.H_1440P, VideoResolution.H_4K ] diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 765ef157e..7945e8586 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts @@ -23,7 +23,7 @@ function checkMissedConfig () { 'redundancy.videos.strategies', 'redundancy.videos.check_interval', 'transcoding.enabled', 'transcoding.threads', 'transcoding.allow_additional_extensions', 'transcoding.hls.enabled', 'transcoding.resolutions.0p', 'transcoding.resolutions.240p', 'transcoding.resolutions.360p', 'transcoding.resolutions.480p', - 'transcoding.resolutions.720p', 'transcoding.resolutions.1080p', 'transcoding.resolutions.2160p', + 'transcoding.resolutions.720p', 'transcoding.resolutions.1080p', 'transcoding.resolutions.1440p', 'transcoding.resolutions.2160p', 'import.videos.http.enabled', 'import.videos.torrent.enabled', 'auto_blacklist.videos.of_users.enabled', 'trending.videos.interval_days', 'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', @@ -41,7 +41,8 @@ function checkMissedConfig () { 'live.enabled', 'live.allow_replay', 'live.max_duration', 'live.max_user_lives', 'live.max_instance_lives', 'live.transcoding.enabled', 'live.transcoding.threads', 'live.transcoding.resolutions.240p', 'live.transcoding.resolutions.360p', 'live.transcoding.resolutions.480p', - 'live.transcoding.resolutions.720p', 'live.transcoding.resolutions.1080p', 'live.transcoding.resolutions.2160p' + 'live.transcoding.resolutions.720p', 'live.transcoding.resolutions.1080p', 'live.transcoding.resolutions.1440p', + 'live.transcoding.resolutions.2160p' ] const requiredAlternatives = [ diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 705223b0a..0f58dc1d4 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -189,6 +189,7 @@ const CONFIG = { get '480p' () { return config.get('transcoding.resolutions.480p') }, get '720p' () { return config.get('transcoding.resolutions.720p') }, get '1080p' () { return config.get('transcoding.resolutions.1080p') }, + get '1440p' () { return config.get('transcoding.resolutions.1440p') }, get '2160p' () { return config.get('transcoding.resolutions.2160p') } }, HLS: { @@ -221,6 +222,7 @@ const CONFIG = { get '480p' () { return config.get('live.transcoding.resolutions.480p') }, get '720p' () { return config.get('live.transcoding.resolutions.720p') }, get '1080p' () { return config.get('live.transcoding.resolutions.1080p') }, + get '1440p' () { return config.get('live.transcoding.resolutions.1440p') }, get '2160p' () { return config.get('live.transcoding.resolutions.2160p') } } } diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 9c1cfa7e7..faabf17d7 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts @@ -45,6 +45,7 @@ const customConfigUpdateValidator = [ body('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), + body('transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), body('transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), @@ -75,6 +76,7 @@ const customConfigUpdateValidator = [ body('live.transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), body('live.transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), body('live.transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), + body('live.transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), body('live.transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), body('search.remoteUri.users').isBoolean().withMessage('Should have a remote URI search for users boolean'), diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index fab440fc5..e36cdeab2 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts @@ -92,6 +92,7 @@ describe('Test config API validators', function () { '480p': true, '720p': false, '1080p': false, + '1440p': false, '2160p': false }, webtorrent: { @@ -118,6 +119,7 @@ describe('Test config API validators', function () { '480p': true, '720p': true, '1080p': true, + '1440p': true, '2160p': true } } diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 257673b66..1c60a7c76 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts @@ -179,6 +179,7 @@ describe('Test live constraints', function () { '480p': true, '720p': true, '1080p': true, + '1440p': true, '2160p': true } } diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index 1128e993c..a5bda009f 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts @@ -75,6 +75,7 @@ describe('Permenant live', function () { '480p': true, '720p': true, '1080p': true, + '1440p': true, '2160p': true } } @@ -164,6 +165,7 @@ describe('Permenant live', function () { '480p': false, '720p': false, '1080p': false, + '1440p': false, '2160p': false } } diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 35fe4e7bd..757e11845 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts @@ -99,6 +99,7 @@ describe('Save replay setting', function () { '480p': true, '720p': true, '1080p': true, + '1440p': true, '2160p': true } } diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index bfaad3688..af25f4800 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts @@ -75,6 +75,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) { expect(data.transcoding.resolutions['480p']).to.be.true expect(data.transcoding.resolutions['720p']).to.be.true expect(data.transcoding.resolutions['1080p']).to.be.true + expect(data.transcoding.resolutions['1440p']).to.be.true expect(data.transcoding.resolutions['2160p']).to.be.true expect(data.transcoding.webtorrent.enabled).to.be.true expect(data.transcoding.hls.enabled).to.be.true @@ -91,6 +92,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) { expect(data.live.transcoding.resolutions['480p']).to.be.false expect(data.live.transcoding.resolutions['720p']).to.be.false expect(data.live.transcoding.resolutions['1080p']).to.be.false + expect(data.live.transcoding.resolutions['1440p']).to.be.false expect(data.live.transcoding.resolutions['2160p']).to.be.false expect(data.import.videos.http.enabled).to.be.true @@ -322,6 +324,7 @@ describe('Test config', function () { '480p': true, '720p': false, '1080p': false, + '1440p': false, '2160p': false }, webtorrent: { @@ -346,6 +349,7 @@ describe('Test config', function () { '480p': true, '720p': true, '1080p': true, + '1440p': true, '2160p': true } } diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index 6fbf32186..82065e770 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts @@ -153,6 +153,7 @@ describe('Test stats (excluding redundancy)', function () { '480p': false, '720p': false, '1080p': false, + '1440p': false, '2160p': false } } diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts index 294a00112..7ddbd5cd9 100644 --- a/server/tests/api/videos/audio-only.ts +++ b/server/tests/api/videos/audio-only.ts @@ -36,6 +36,7 @@ describe('Test audio only video transcoding', function () { '480p': false, '720p': false, '1080p': false, + '1440p': false, '2160p': false }, hls: { diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index f3dbbb114..d1720d0d9 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -202,6 +202,7 @@ describe('Test HLS videos', function () { '480p': true, '720p': true, '1080p': true, + '1440p': true, '2160p': true }, hls: { diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index 997a9a1fd..5bc1687cd 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -33,6 +33,7 @@ describe('Test create transcoding jobs', function () { '480p': true, '720p': true, '1080p': true, + '1440p': true, '2160p': true }, hls: { diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts index 8702659c4..f7c488c0b 100644 --- a/shared/extra-utils/server/config.ts +++ b/shared/extra-utils/server/config.ts @@ -117,6 +117,7 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti '480p': true, '720p': false, '1080p': false, + '1440p': false, '2160p': false }, webtorrent: { @@ -141,6 +142,7 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti '480p': true, '720p': true, '1080p': true, + '1440p': true, '2160p': true } } diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts index 67e05e23f..9a6a24923 100644 --- a/shared/models/server/custom-config.model.ts +++ b/shared/models/server/custom-config.model.ts @@ -7,6 +7,7 @@ export type ConfigResolutions = { '480p': boolean '720p': boolean '1080p': boolean + '1440p': boolean '2160p': boolean } diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts index dcd55dad8..a5d2ac7fa 100644 --- a/shared/models/videos/video-resolution.enum.ts +++ b/shared/models/videos/video-resolution.enum.ts @@ -7,6 +7,7 @@ export const enum VideoResolution { H_480P = 480, H_720P = 720, H_1080P = 1080, + H_1440P = 1440, H_4K = 2160 } @@ -53,9 +54,15 @@ function getBaseBitrate (resolution: number) { return 5200 * 1000 } + if (resolution <= VideoResolution.H_1440P) { + // quality according to Google Live Encoder: 6000 - 13000 Kbps + // Quality according to YouTube Video Info: 8600 (av01) - 17000 (vp9.2) Kbps + return 10_000 * 1000 + } + // 4K // quality according to Google Live Encoder: 13000 - 34000 Kbps - return 22000 * 1000 + return 22_000 * 1000 } /** diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml index 74b2dee28..fe4552ff7 100644 --- a/support/doc/api/openapi.yaml +++ b/support/doc/api/openapi.yaml @@ -3941,7 +3941,7 @@ components: properties: id: type: integer - description: 'Video resolution (240, 360, 720 ...)' + description: 'Video resolution (240, 360, 720, 1080, 1440 or 2160)' example: 240 label: type: string @@ -4829,6 +4829,8 @@ components: type: boolean 1080p: type: boolean + 1440p: + type: boolean 2160p: type: boolean hls: diff --git a/support/docker/production/config/custom-environment-variables.yaml b/support/docker/production/config/custom-environment-variables.yaml index c4c627551..954c3714b 100644 --- a/support/docker/production/config/custom-environment-variables.yaml +++ b/support/docker/production/config/custom-environment-variables.yaml @@ -106,6 +106,9 @@ transcoding: 1080p: __name: "PEERTUBE_TRANSCODING_1080P" __format: "json" + 1440p: + __name: "PEERTUBE_TRANSCODING_1440P" + __format: "json" 2160p: __name: "PEERTUBE_TRANSCODING_2160P" __format: "json" -- 2.41.0