Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Improve 4K video quality after transcoding

Chocobozzzad3405d087b3
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 adce1b2d43..ee6d2c489f 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 fcbbf17e86..e4e2d22730 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 0ab99ac458..c025426bb9 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 7dabe433c1..8d3921614d 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 40a2c972b9..99900ca4aa 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 c180da8321..8041e7b3b4 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 1505804de4..68c5a2e2b2 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 7da5e71004..51efa2e8b5 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 bd4ac12155..d5b8788300 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"