Improve 4K video quality after transcoding
authorChocobozzz <me@florianbigard.com>
Thu, 6 Jun 2019 12:45:57 +0000 (14:45 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 6 Jun 2019 12:45:57 +0000 (14:45 +0200)
client/src/app/+admin/users/user-edit/user-edit.ts
config/default.yaml
config/production.yaml.example
config/test.yaml
server/controllers/api/videos/index.ts
server/helpers/ffmpeg-utils.ts
shared/extra-utils/server/follows.ts
shared/models/videos/video-resolution.enum.ts
support/docker/production/config/custom-environment-variables.yaml

index adce1b2d43cc0346589e752a3cf4c10a3504dbeb..ee6d2c489fb1ee748037ef8be9c56233da66f01e 100644 (file)
@@ -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) {
index fcbbf17e86d2b5c700a594bf2c7d9cc9c18c3c49..e4e2d2273060d8ba23e491d54325b9ed7a7720ef 100644 (file)
@@ -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:
index 0ab99ac458b30210918531ff3300dcac38771bc2..c025426bb9a8986cad7b4343b2eb22d0c481a5e3 100644 (file)
@@ -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:
index 7dabe433c162fee82b9469fe4e063bbb5be3c03e..8d3921614df1fe98fcbf12e61f289cfc9ce6eb5b 100644 (file)
@@ -63,6 +63,7 @@ transcoding:
     480p: true
     720p: true
     1080p: true
+    2160p: true
   hls:
     enabled: true
 
index 40a2c972b9ccef040387534637d179d15f690637..99900ca4aa97780db3a08dc70362610eba601a2d 100644 (file)
@@ -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
index c180da832135cc1c3bc4e4ea743d4efad53eb4bb..8041e7b3b494168edbe80e8e0e9e5827168c2feb 100644 (file)
@@ -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) {
index 1505804de45537fe8225f11aa06dec3589487942..68c5a2e2b24cd6115ab3c4b6a8a387742e645965 100644 (file)
@@ -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'
index 7da5e71004dc1f061ece37e0c53b0daab9fdc081..51efa2e8b569966bd8bb71da837277513e1a94c0 100644 (file)
@@ -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
   }
 }
 
index bd4ac121555f6b6938b48bba534bd814cb19b7b7..d5b8788300e10e2fb32600606db58e5180e153c8 100644 (file)
@@ -106,6 +106,9 @@ transcoding:
     1080:
       __name: "PEERTUBE_TRANSCODING_1080P"
       __format: "json"
+    2160:
+      __name: "PEERTUBE_TRANSCODING_2160P"
+      __format: "json"
 
 instance:
   name: "PEERTUBE_INSTANCE_NAME"