aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts16
-rw-r--r--server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts4
-rw-r--r--server/lib/transcoding/transcoding-resolutions.ts21
-rw-r--r--server/lib/transcoding/web-transcoding.ts28
4 files changed, 33 insertions, 36 deletions
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 39f078bf0..f8758f170 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -75,21 +75,21 @@ export {
75// --------------------------------------------------------------------------- 75// ---------------------------------------------------------------------------
76 76
77async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { 77async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
78 logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid)) 78 logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })
79 79
80 await mergeAudioVideofile({ video, resolution: payload.resolution, fps: payload.fps, job }) 80 await mergeAudioVideofile({ video, resolution: payload.resolution, fps: payload.fps, job })
81 81
82 logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 82 logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload })
83 83
84 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video }) 84 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video })
85} 85}
86 86
87async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { 87async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
88 logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid)) 88 logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })
89 89
90 await optimizeOriginalVideofile({ video, inputVideoFile: video.getMaxQualityFile(), quickTranscode: payload.quickTranscode, job }) 90 await optimizeOriginalVideofile({ video, inputVideoFile: video.getMaxQualityFile(), quickTranscode: payload.quickTranscode, job })
91 91
92 logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 92 logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload })
93 93
94 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video }) 94 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video })
95} 95}
@@ -97,11 +97,11 @@ async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodi
97// --------------------------------------------------------------------------- 97// ---------------------------------------------------------------------------
98 98
99async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorrentResolutionTranscodingPayload, video: MVideoFullLight) { 99async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorrentResolutionTranscodingPayload, video: MVideoFullLight) {
100 logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid)) 100 logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })
101 101
102 await transcodeNewWebTorrentResolution({ video, resolution: payload.resolution, fps: payload.fps, job }) 102 await transcodeNewWebTorrentResolution({ video, resolution: payload.resolution, fps: payload.fps, job })
103 103
104 logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 104 logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload })
105 105
106 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video }) 106 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video })
107} 107}
@@ -109,7 +109,7 @@ async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorren
109// --------------------------------------------------------------------------- 109// ---------------------------------------------------------------------------
110 110
111async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: MVideoFullLight) { 111async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: MVideoFullLight) {
112 logger.info('Handling HLS transcoding job for %s.', videoArg.uuid, lTags(videoArg.uuid)) 112 logger.info('Handling HLS transcoding job for %s.', videoArg.uuid, lTags(videoArg.uuid), { payload })
113 113
114 const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(videoArg.uuid) 114 const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(videoArg.uuid)
115 let video: MVideoFullLight 115 let video: MVideoFullLight
@@ -138,7 +138,7 @@ async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg:
138 inputFileMutexReleaser() 138 inputFileMutexReleaser()
139 } 139 }
140 140
141 logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 141 logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload })
142 142
143 if (payload.deleteWebTorrentFiles === true) { 143 if (payload.deleteWebTorrentFiles === true) {
144 logger.info('Removing WebTorrent files of %s now we have a HLS version of it.', video.uuid, lTags(video.uuid)) 144 logger.info('Removing WebTorrent files of %s now we have a HLS version of it.', video.uuid, lTags(video.uuid))
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'
19import { getTranscodingJobPriority } from '../../transcoding-priority' 19import { getTranscodingJobPriority } from '../../transcoding-priority'
20import { canDoQuickTranscode } from '../../transcoding-quick-transcode' 20import { canDoQuickTranscode } from '../../transcoding-quick-transcode'
21import { computeResolutionsToTranscode } from '../../transcoding-resolutions' 21import { buildOriginalFileResolution, computeResolutionsToTranscode } from '../../transcoding-resolutions'
22import { AbstractJobBuilder } from './abstract-job-builder' 22import { AbstractJobBuilder } from './abstract-job-builder'
23 23
24export class TranscodingJobQueueBuilder extends AbstractJobBuilder { 24export 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'
2import { toEven } from '@shared/core-utils' 2import { toEven } from '@shared/core-utils'
3import { VideoResolution } from '@shared/models' 3import { VideoResolution } from '@shared/models'
4 4
5export 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
5export function computeResolutionsToTranscode (options: { 26export 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'
3import { basename, join } from 'path' 3import { basename, join } from 'path'
4import { computeOutputFPS } from '@server/helpers/ffmpeg' 4import { computeOutputFPS } from '@server/helpers/ffmpeg'
5import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 5import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
6import { VideoModel } from '@server/models/video/video'
6import { MVideoFile, MVideoFullLight } from '@server/types/models' 7import { MVideoFile, MVideoFullLight } from '@server/types/models'
7import { toEven } from '@shared/core-utils'
8import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, TranscodeVODOptionsType } from '@shared/ffmpeg' 8import { ffprobePromise, getVideoStreamDuration, getVideoStreamFPS, TranscodeVODOptionsType } from '@shared/ffmpeg'
9import { VideoResolution, VideoStorage } from '@shared/models' 9import { VideoResolution, VideoStorage } from '@shared/models'
10import { CONFIG } from '../../initializers/config' 10import { CONFIG } from '../../initializers/config'
@@ -13,8 +13,7 @@ import { generateWebTorrentVideoFilename } from '../paths'
13import { buildFileMetadata } from '../video-file' 13import { buildFileMetadata } from '../video-file'
14import { VideoPathManager } from '../video-path-manager' 14import { VideoPathManager } from '../video-path-manager'
15import { buildFFmpegVOD } from './shared' 15import { buildFFmpegVOD } from './shared'
16import { computeResolutionsToTranscode } from './transcoding-resolutions' 16import { buildOriginalFileResolution } from './transcoding-resolutions'
17import { 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.
20export async function optimizeOriginalVideofile (options: { 19export async function optimizeOriginalVideofile (options: {
@@ -248,26 +247,3 @@ export async function onWebTorrentVideoFileTranscoding (options: {
248 mutexReleaser() 247 mutexReleaser()
249 } 248 }
250} 249}
251
252// ---------------------------------------------------------------------------
253
254function 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}