aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-05 10:36:19 +0200
committerChocobozzz <me@florianbigard.com>2022-08-09 09:18:07 +0200
commit84cae54e7a2595bea0c3ea106a4d111fd11a4ec6 (patch)
tree03fe73edf049ce60df6bbc34dcfb2031c07ea59c /server/lib/job-queue/handlers
parent7e0f50d6e0c7dc583d40e196c283eb20dc386ae6 (diff)
downloadPeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.tar.gz
PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.tar.zst
PeerTube-84cae54e7a2595bea0c3ea106a4d111fd11a4ec6.zip
Add option to not transcode original resolution
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts3
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts26
2 files changed, 10 insertions, 19 deletions
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index 10507fb83..78d0b2192 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -213,13 +213,12 @@ async function assignReplayFilesToVideo (options: {
213 const probe = await ffprobePromise(concatenatedTsFilePath) 213 const probe = await ffprobePromise(concatenatedTsFilePath)
214 const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe) 214 const { audioStream } = await getAudioStream(concatenatedTsFilePath, probe)
215 215
216 const { resolution, isPortraitMode } = await getVideoStreamDimensionsInfo(concatenatedTsFilePath, probe) 216 const { resolution } = await getVideoStreamDimensionsInfo(concatenatedTsFilePath, probe)
217 217
218 const { resolutionPlaylistPath: outputPath } = await generateHlsPlaylistResolutionFromTS({ 218 const { resolutionPlaylistPath: outputPath } = await generateHlsPlaylistResolutionFromTS({
219 video, 219 video,
220 concatenatedTsFilePath, 220 concatenatedTsFilePath,
221 resolution, 221 resolution,
222 isPortraitMode,
223 isAAC: audioStream?.codec_name === 'aac' 222 isAAC: audioStream?.codec_name === 'aac'
224 }) 223 })
225 224
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index d3fb7778b..b07876a1c 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -1,5 +1,6 @@
1import { Job } from 'bull' 1import { Job } from 'bull'
2import { TranscodeVODOptionsType } from '@server/helpers/ffmpeg' 2import { TranscodeVODOptionsType } from '@server/helpers/ffmpeg'
3import { Hooks } from '@server/lib/plugins/hooks'
3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' 4import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
4import { VideoPathManager } from '@server/lib/video-path-manager' 5import { VideoPathManager } from '@server/lib/video-path-manager'
5import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state' 6import { moveToFailedTranscodingState, moveToNextState } from '@server/lib/video-state'
@@ -16,7 +17,7 @@ import {
16 VideoTranscodingPayload 17 VideoTranscodingPayload
17} from '@shared/models' 18} from '@shared/models'
18import { retryTransactionWrapper } from '../../../helpers/database-utils' 19import { retryTransactionWrapper } from '../../../helpers/database-utils'
19import { computeLowerResolutionsToTranscode } from '../../../helpers/ffmpeg' 20import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg'
20import { logger, loggerTagsFactory } from '../../../helpers/logger' 21import { logger, loggerTagsFactory } from '../../../helpers/logger'
21import { CONFIG } from '../../../initializers/config' 22import { CONFIG } from '../../../initializers/config'
22import { VideoModel } from '../../../models/video/video' 23import { VideoModel } from '../../../models/video/video'
@@ -26,7 +27,6 @@ import {
26 optimizeOriginalVideofile, 27 optimizeOriginalVideofile,
27 transcodeNewWebTorrentResolution 28 transcodeNewWebTorrentResolution
28} from '../../transcoding/transcoding' 29} from '../../transcoding/transcoding'
29import { Hooks } from '@server/lib/plugins/hooks'
30 30
31type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> 31type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
32 32
@@ -99,7 +99,6 @@ async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MV
99 videoInputPath, 99 videoInputPath,
100 resolution: payload.resolution, 100 resolution: payload.resolution,
101 copyCodecs: payload.copyCodecs, 101 copyCodecs: payload.copyCodecs,
102 isPortraitMode: payload.isPortraitMode || false,
103 job 102 job
104 }) 103 })
105 }) 104 })
@@ -117,7 +116,7 @@ async function handleNewWebTorrentResolutionJob (
117) { 116) {
118 logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid)) 117 logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid))
119 118
120 await transcodeNewWebTorrentResolution(video, payload.resolution, payload.isPortraitMode || false, job) 119 await transcodeNewWebTorrentResolution({ video, resolution: payload.resolution, job })
121 120
122 logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 121 logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid))
123 122
@@ -127,7 +126,7 @@ async function handleNewWebTorrentResolutionJob (
127async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { 126async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
128 logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid)) 127 logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid))
129 128
130 await mergeAudioVideofile(video, payload.resolution, job) 129 await mergeAudioVideofile({ video, resolution: payload.resolution, job })
131 130
132 logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 131 logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid))
133 132
@@ -137,7 +136,7 @@ async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTrans
137async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { 136async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
138 logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid)) 137 logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid))
139 138
140 const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job) 139 const { transcodeType } = await optimizeOriginalVideofile({ video, inputVideoFile: video.getMaxQualityFile(), job })
141 140
142 logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 141 logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid))
143 142
@@ -161,7 +160,6 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay
161 video, 160 video,
162 user, 161 user,
163 videoFileResolution: payload.resolution, 162 videoFileResolution: payload.resolution,
164 isPortraitMode: payload.isPortraitMode,
165 hasAudio: payload.hasAudio, 163 hasAudio: payload.hasAudio,
166 isNewVideo: payload.isNewVideo ?? true, 164 isNewVideo: payload.isNewVideo ?? true,
167 type: 'hls' 165 type: 'hls'
@@ -178,7 +176,7 @@ async function onVideoFirstWebTorrentTranscoding (
178 transcodeType: TranscodeVODOptionsType, 176 transcodeType: TranscodeVODOptionsType,
179 user: MUserId 177 user: MUserId
180) { 178) {
181 const { resolution, isPortraitMode, audioStream } = await videoArg.probeMaxQualityFile() 179 const { resolution, audioStream } = await videoArg.probeMaxQualityFile()
182 180
183 // Maybe the video changed in database, refresh it 181 // Maybe the video changed in database, refresh it
184 const videoDatabase = await VideoModel.loadFull(videoArg.uuid) 182 const videoDatabase = await VideoModel.loadFull(videoArg.uuid)
@@ -189,7 +187,6 @@ async function onVideoFirstWebTorrentTranscoding (
189 const originalFileHLSPayload = { 187 const originalFileHLSPayload = {
190 ...payload, 188 ...payload,
191 189
192 isPortraitMode,
193 hasAudio: !!audioStream, 190 hasAudio: !!audioStream,
194 resolution: videoDatabase.getMaxQualityFile().resolution, 191 resolution: videoDatabase.getMaxQualityFile().resolution,
195 // If we quick transcoded original file, force transcoding for HLS to avoid some weird playback issues 192 // If we quick transcoded original file, force transcoding for HLS to avoid some weird playback issues
@@ -202,7 +199,6 @@ async function onVideoFirstWebTorrentTranscoding (
202 user, 199 user,
203 videoFileResolution: resolution, 200 videoFileResolution: resolution,
204 hasAudio: !!audioStream, 201 hasAudio: !!audioStream,
205 isPortraitMode,
206 type: 'webtorrent', 202 type: 'webtorrent',
207 isNewVideo: payload.isNewVideo ?? true 203 isNewVideo: payload.isNewVideo ?? true
208 }) 204 })
@@ -235,7 +231,6 @@ async function createHlsJobIfEnabled (user: MUserId, payload: {
235 videoUUID: string 231 videoUUID: string
236 resolution: number 232 resolution: number
237 hasAudio: boolean 233 hasAudio: boolean
238 isPortraitMode?: boolean
239 copyCodecs: boolean 234 copyCodecs: boolean
240 isMaxQuality: boolean 235 isMaxQuality: boolean
241 isNewVideo?: boolean 236 isNewVideo?: boolean
@@ -250,7 +245,7 @@ async function createHlsJobIfEnabled (user: MUserId, payload: {
250 type: 'new-resolution-to-hls', 245 type: 'new-resolution-to-hls',
251 autoDeleteWebTorrentIfNeeded: true, 246 autoDeleteWebTorrentIfNeeded: true,
252 247
253 ...pick(payload, [ 'videoUUID', 'resolution', 'isPortraitMode', 'copyCodecs', 'isMaxQuality', 'isNewVideo', 'hasAudio' ]) 248 ...pick(payload, [ 'videoUUID', 'resolution', 'copyCodecs', 'isMaxQuality', 'isNewVideo', 'hasAudio' ])
254 } 249 }
255 250
256 await addTranscodingJob(hlsTranscodingPayload, jobOptions) 251 await addTranscodingJob(hlsTranscodingPayload, jobOptions)
@@ -262,16 +257,15 @@ async function createLowerResolutionsJobs (options: {
262 video: MVideoFullLight 257 video: MVideoFullLight
263 user: MUserId 258 user: MUserId
264 videoFileResolution: number 259 videoFileResolution: number
265 isPortraitMode: boolean
266 hasAudio: boolean 260 hasAudio: boolean
267 isNewVideo: boolean 261 isNewVideo: boolean
268 type: 'hls' | 'webtorrent' 262 type: 'hls' | 'webtorrent'
269}) { 263}) {
270 const { video, user, videoFileResolution, isPortraitMode, isNewVideo, hasAudio, type } = options 264 const { video, user, videoFileResolution, isNewVideo, hasAudio, type } = options
271 265
272 // Create transcoding jobs if there are enabled resolutions 266 // Create transcoding jobs if there are enabled resolutions
273 const resolutionsEnabled = await Hooks.wrapObject( 267 const resolutionsEnabled = await Hooks.wrapObject(
274 computeLowerResolutionsToTranscode(videoFileResolution, 'vod'), 268 computeResolutionsToTranscode({ inputResolution: videoFileResolution, type: 'vod', includeInputResolution: false }),
275 'filter:transcoding.auto.lower-resolutions-to-transcode.result', 269 'filter:transcoding.auto.lower-resolutions-to-transcode.result',
276 options 270 options
277 ) 271 )
@@ -289,7 +283,6 @@ async function createLowerResolutionsJobs (options: {
289 type: 'new-resolution-to-webtorrent', 283 type: 'new-resolution-to-webtorrent',
290 videoUUID: video.uuid, 284 videoUUID: video.uuid,
291 resolution, 285 resolution,
292 isPortraitMode,
293 hasAudio, 286 hasAudio,
294 createHLSIfNeeded: true, 287 createHLSIfNeeded: true,
295 isNewVideo 288 isNewVideo
@@ -303,7 +296,6 @@ async function createLowerResolutionsJobs (options: {
303 type: 'new-resolution-to-hls', 296 type: 'new-resolution-to-hls',
304 videoUUID: video.uuid, 297 videoUUID: video.uuid,
305 resolution, 298 resolution,
306 isPortraitMode,
307 hasAudio, 299 hasAudio,
308 copyCodecs: false, 300 copyCodecs: false,
309 isMaxQuality: false, 301 isMaxQuality: false,