diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-30 09:35:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-30 09:35:21 +0200 |
commit | 29c7319c8a42d5c4831d08a80f4d111d3a72f52c (patch) | |
tree | 476b180ea7f84fd4d55b12fb1c06285676e173fd /server/lib/transcoding | |
parent | 89eda2aab005e6c8f548acc80471ce4bad039ecd (diff) | |
download | PeerTube-29c7319c8a42d5c4831d08a80f4d111d3a72f52c.tar.gz PeerTube-29c7319c8a42d5c4831d08a80f4d111d3a72f52c.tar.zst PeerTube-29c7319c8a42d5c4831d08a80f4d111d3a72f52c.zip |
Fix transcoding error
When transcoding.always_transcode_original_resolution is false
Diffstat (limited to 'server/lib/transcoding')
3 files changed, 25 insertions, 28 deletions
diff --git a/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts b/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts index fa2ac70bf..4f802e2a6 100644 --- a/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts +++ b/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts | |||
@@ -18,7 +18,7 @@ import { | |||
18 | } from '@shared/models' | 18 | } from '@shared/models' |
19 | import { getTranscodingJobPriority } from '../../transcoding-priority' | 19 | import { getTranscodingJobPriority } from '../../transcoding-priority' |
20 | import { canDoQuickTranscode } from '../../transcoding-quick-transcode' | 20 | import { canDoQuickTranscode } from '../../transcoding-quick-transcode' |
21 | import { computeResolutionsToTranscode } from '../../transcoding-resolutions' | 21 | import { buildOriginalFileResolution, computeResolutionsToTranscode } from '../../transcoding-resolutions' |
22 | import { AbstractJobBuilder } from './abstract-job-builder' | 22 | import { AbstractJobBuilder } from './abstract-job-builder' |
23 | 23 | ||
24 | export class TranscodingJobQueueBuilder extends AbstractJobBuilder { | 24 | export class TranscodingJobQueueBuilder extends AbstractJobBuilder { |
@@ -55,7 +55,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder { | |||
55 | 55 | ||
56 | const maxResolution = await isAudioFile(videoFilePath, probe) | 56 | const maxResolution = await isAudioFile(videoFilePath, probe) |
57 | ? DEFAULT_AUDIO_RESOLUTION | 57 | ? DEFAULT_AUDIO_RESOLUTION |
58 | : resolution | 58 | : buildOriginalFileResolution(resolution) |
59 | 59 | ||
60 | if (CONFIG.TRANSCODING.HLS.ENABLED === true) { | 60 | if (CONFIG.TRANSCODING.HLS.ENABLED === true) { |
61 | nextTranscodingSequentialJobPayloads.push([ | 61 | nextTranscodingSequentialJobPayloads.push([ |
diff --git a/server/lib/transcoding/transcoding-resolutions.ts b/server/lib/transcoding/transcoding-resolutions.ts index 91f4d18d8..9a6bf5722 100644 --- a/server/lib/transcoding/transcoding-resolutions.ts +++ b/server/lib/transcoding/transcoding-resolutions.ts | |||
@@ -2,6 +2,27 @@ import { CONFIG } from '@server/initializers/config' | |||
2 | import { toEven } from '@shared/core-utils' | 2 | import { toEven } from '@shared/core-utils' |
3 | import { VideoResolution } from '@shared/models' | 3 | import { VideoResolution } from '@shared/models' |
4 | 4 | ||
5 | export function buildOriginalFileResolution (inputResolution: number) { | ||
6 | if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) { | ||
7 | return toEven(inputResolution) | ||
8 | } | ||
9 | |||
10 | const resolutions = computeResolutionsToTranscode({ | ||
11 | input: inputResolution, | ||
12 | type: 'vod', | ||
13 | includeInput: false, | ||
14 | strictLower: false, | ||
15 | // We don't really care about the audio resolution in this context | ||
16 | hasAudio: true | ||
17 | }) | ||
18 | |||
19 | if (resolutions.length === 0) { | ||
20 | return toEven(inputResolution) | ||
21 | } | ||
22 | |||
23 | return Math.max(...resolutions) | ||
24 | } | ||
25 | |||
5 | export function computeResolutionsToTranscode (options: { | 26 | export function computeResolutionsToTranscode (options: { |
6 | input: number | 27 | input: number |
7 | type: 'vod' | 'live' | 28 | type: 'vod' | 'live' |
diff --git a/server/lib/transcoding/web-transcoding.ts b/server/lib/transcoding/web-transcoding.ts index 22bd238ae..7cc8f20bc 100644 --- a/server/lib/transcoding/web-transcoding.ts +++ b/server/lib/transcoding/web-transcoding.ts | |||
@@ -3,8 +3,8 @@ import { copyFile, move, remove, stat } from 'fs-extra' | |||
3 | import { basename, join } from 'path' | 3 | import { basename, join } from 'path' |
4 | import { computeOutputFPS } from '@server/helpers/ffmpeg' | 4 | import { computeOutputFPS } from '@server/helpers/ffmpeg' |
5 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 5 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
6 | import { VideoModel } from '@server/models/video/video' | ||
6 | import { MVideoFile, MVideoFullLight } from '@server/types/models' | 7 | import { MVideoFile, MVideoFullLight } from '@server/types/models' |
7 | import { toEven } from '@shared/core-utils' | ||
8 | import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, TranscodeVODOptionsType } from '@shared/ffmpeg' | 8 | import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, TranscodeVODOptionsType } from '@shared/ffmpeg' |
9 | import { VideoResolution, VideoStorage } from '@shared/models' | 9 | import { VideoResolution, VideoStorage } from '@shared/models' |
10 | import { CONFIG } from '../../initializers/config' | 10 | import { CONFIG } from '../../initializers/config' |
@@ -13,8 +13,7 @@ import { generateWebTorrentVideoFilename } from '../paths' | |||
13 | import { buildFileMetadata } from '../video-file' | 13 | import { buildFileMetadata } from '../video-file' |
14 | import { VideoPathManager } from '../video-path-manager' | 14 | import { VideoPathManager } from '../video-path-manager' |
15 | import { buildFFmpegVOD } from './shared' | 15 | import { buildFFmpegVOD } from './shared' |
16 | import { computeResolutionsToTranscode } from './transcoding-resolutions' | 16 | import { buildOriginalFileResolution } from './transcoding-resolutions' |
17 | import { VideoModel } from '@server/models/video/video' | ||
18 | 17 | ||
19 | // Optimize the original video file and replace it. The resolution is not changed. | 18 | // Optimize the original video file and replace it. The resolution is not changed. |
20 | export async function optimizeOriginalVideofile (options: { | 19 | export async function optimizeOriginalVideofile (options: { |
@@ -248,26 +247,3 @@ export async function onWebTorrentVideoFileTranscoding (options: { | |||
248 | mutexReleaser() | 247 | mutexReleaser() |
249 | } | 248 | } |
250 | } | 249 | } |
251 | |||
252 | // --------------------------------------------------------------------------- | ||
253 | |||
254 | function buildOriginalFileResolution (inputResolution: number) { | ||
255 | if (CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION === true) { | ||
256 | return toEven(inputResolution) | ||
257 | } | ||
258 | |||
259 | const resolutions = computeResolutionsToTranscode({ | ||
260 | input: inputResolution, | ||
261 | type: 'vod', | ||
262 | includeInput: false, | ||
263 | strictLower: false, | ||
264 | // We don't really care about the audio resolution in this context | ||
265 | hasAudio: true | ||
266 | }) | ||
267 | |||
268 | if (resolutions.length === 0) { | ||
269 | return toEven(inputResolution) | ||
270 | } | ||
271 | |||
272 | return Math.max(...resolutions) | ||
273 | } | ||