瀏覽代碼

Improve 4K video quality after transcoding

Chocobozzz 5 年之前
父節點
當前提交
ad3405d087

+ 3 - 2
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) {

+ 1 - 0
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:

+ 1 - 0
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:

+ 1 - 0
config/test.yaml

@@ -63,6 +63,7 @@ transcoding:
     480p: true
     720p: true
     1080p: true
+    2160p: true
   hls:
     enabled: true
 

+ 3 - 3
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

+ 2 - 1
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) {

+ 1 - 1
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'

+ 7 - 3
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
   }
 }
 

+ 3 - 0
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"