From ad3405d087b306efa5eb62a69c9b797b04eab4ce Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 6 Jun 2019 14:45:57 +0200 Subject: [PATCH] Improve 4K video quality after transcoding --- client/src/app/+admin/users/user-edit/user-edit.ts | 5 +++-- config/default.yaml | 1 + config/production.yaml.example | 1 + config/test.yaml | 1 + server/controllers/api/videos/index.ts | 6 +++--- server/helpers/ffmpeg-utils.ts | 3 ++- shared/extra-utils/server/follows.ts | 2 +- shared/models/videos/video-resolution.enum.ts | 10 +++++++--- .../config/custom-environment-variables.yaml | 3 +++ 9 files changed, 22 insertions(+), 10 deletions(-) diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts index adce1b2d4..ee6d2c489 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/users/user-edit/user-edit.ts @@ -7,7 +7,8 @@ import { UserAdminFlag } from '@shared/models/users/user-flag.model' export abstract class UserEdit extends FormReactive { videoQuotaOptions: { value: string, label: string }[] = [] videoQuotaDailyOptions: { value: string, label: string }[] = [] - roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) + roles = Object.keys(USER_ROLE_LABELS) + .map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) username: string userId: number @@ -27,7 +28,7 @@ export abstract class UserEdit extends FormReactive { const transcodingConfig = this.serverService.getConfig().transcoding const resolutions = transcodingConfig.enabledResolutions - const higherResolution = VideoResolution.H_1080P + const higherResolution = VideoResolution.H_4K let multiplier = 0 for (const resolution of resolutions) { diff --git a/config/default.yaml b/config/default.yaml index fcbbf17e8..e4e2d2273 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -189,6 +189,7 @@ transcoding: 480p: false 720p: false 1080p: false + 2160p: false # /!\ EXPERIMENTAL /!\ # /!\ Requires ffmpeg >= 4 # Generate HLS playlists and fragmented MP4 files. Better playback than with WebTorrent: diff --git a/config/production.yaml.example b/config/production.yaml.example index 0ab99ac45..c025426bb 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -197,6 +197,7 @@ transcoding: 480p: false 720p: false 1080p: false + 2160p: false # /!\ EXPERIMENTAL /!\ # /!\ Requires ffmpeg >= 4 # Generate HLS playlists and fragmented MP4 files. Better playback than with WebTorrent: diff --git a/config/test.yaml b/config/test.yaml index 7dabe433c..8d3921614 100644 --- a/config/test.yaml +++ b/config/test.yaml @@ -63,6 +63,7 @@ transcoding: 480p: true 720p: true 1080p: true + 2160p: true hls: enabled: true diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 40a2c972b..99900ca4a 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -205,11 +205,11 @@ async function addVideo (req: express.Request, res: express.Response) { } const videoFile = new VideoFileModel(videoFileData) - if (!videoFile.isAudio()) { + if (videoFile.isAudio()) { + videoFile.resolution = DEFAULT_AUDIO_RESOLUTION + } else { videoFile.fps = await getVideoFileFPS(videoPhysicalFile.path) videoFile.resolution = (await getVideoFileResolution(videoPhysicalFile.path)).videoFileResolution - } else { - videoFile.resolution = DEFAULT_AUDIO_RESOLUTION } // Move physical file diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index c180da832..8041e7b3b 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -18,7 +18,8 @@ function computeResolutionsToTranscode (videoFileHeight: number) { VideoResolution.H_360P, VideoResolution.H_720P, VideoResolution.H_240P, - VideoResolution.H_1080P + VideoResolution.H_1080P, + VideoResolution.H_4K ] for (const resolution of resolutions) { diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts index 1505804de..68c5a2e2b 100644 --- a/shared/extra-utils/server/follows.ts +++ b/shared/extra-utils/server/follows.ts @@ -1,7 +1,7 @@ import * as request from 'supertest' import { ServerInfo } from './servers' import { waitJobs } from './jobs' -import { makeGetRequest, makePostBodyRequest } from '..' +import { makePostBodyRequest } from '../requests/requests' function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) { const path = '/api/v1/server/followers' diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts index 7da5e7100..51efa2e8b 100644 --- a/shared/models/videos/video-resolution.enum.ts +++ b/shared/models/videos/video-resolution.enum.ts @@ -5,7 +5,8 @@ export enum VideoResolution { H_360P = 360, H_480P = 480, H_720P = 720, - H_1080P = 1080 + H_1080P = 1080, + H_4K = 2160 } /** @@ -33,11 +34,14 @@ function getBaseBitrate (resolution: VideoResolution) { // quality according to Google Live Encoder: 1,500 - 4,000 Kbps // Quality according to YouTube Video Info: 1752 Kbps return 1750 * 1000 - case VideoResolution.H_1080P: // fallthrough - default: + case VideoResolution.H_1080P: // quality according to Google Live Encoder: 3000 - 6000 Kbps // Quality according to YouTube Video Info: 3277 Kbps return 3300 * 1000 + case VideoResolution.H_4K: // fallthrough + default: + // quality according to Google Live Encoder: 13000 - 34000 Kbps + return 15000 * 1000 } } diff --git a/support/docker/production/config/custom-environment-variables.yaml b/support/docker/production/config/custom-environment-variables.yaml index bd4ac1215..d5b878830 100644 --- a/support/docker/production/config/custom-environment-variables.yaml +++ b/support/docker/production/config/custom-environment-variables.yaml @@ -106,6 +106,9 @@ transcoding: 1080: __name: "PEERTUBE_TRANSCODING_1080P" __format: "json" + 2160: + __name: "PEERTUBE_TRANSCODING_2160P" + __format: "json" instance: name: "PEERTUBE_INSTANCE_NAME" -- 2.41.0