aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-transcoding.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-03 14:40:52 +0100
committerChocobozzz <me@florianbigard.com>2021-12-03 14:40:52 +0100
commit9ea02c48a7a47b5bbed261e847d7d671e266a073 (patch)
tree9aa64f0f6387a7a3162956ce9730a90c0cb6d3f7 /server/lib/job-queue/handlers/video-transcoding.ts
parent6d472b4046084e5f477124b11ac62dca9f6a1a63 (diff)
parent025d858e7997d6b9895fa6b7beaf23bf5ff814af (diff)
downloadPeerTube-9ea02c48a7a47b5bbed261e847d7d671e266a073.tar.gz
PeerTube-9ea02c48a7a47b5bbed261e847d7d671e266a073.tar.zst
PeerTube-9ea02c48a7a47b5bbed261e847d7d671e266a073.zip
Merge branch 'release/4.0.0' into develop
Diffstat (limited to 'server/lib/job-queue/handlers/video-transcoding.ts')
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts27
1 files changed, 14 insertions, 13 deletions
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 0d80eb6c5..0edcdcba3 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -53,6 +53,7 @@ async function processVideoTranscoding (job: Job) {
53 53
54 if (!handler) { 54 if (!handler) {
55 await moveToFailedTranscodingState(video) 55 await moveToFailedTranscodingState(video)
56 await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
56 57
57 throw new Error('Cannot find transcoding handler for ' + payload.type) 58 throw new Error('Cannot find transcoding handler for ' + payload.type)
58 } 59 }
@@ -62,6 +63,8 @@ async function processVideoTranscoding (job: Job) {
62 } catch (error) { 63 } catch (error) {
63 await moveToFailedTranscodingState(video) 64 await moveToFailedTranscodingState(video)
64 65
66 await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode')
67
65 throw error 68 throw error
66 } 69 }
67 70
@@ -69,6 +72,12 @@ async function processVideoTranscoding (job: Job) {
69} 72}
70 73
71// --------------------------------------------------------------------------- 74// ---------------------------------------------------------------------------
75
76export {
77 processVideoTranscoding
78}
79
80// ---------------------------------------------------------------------------
72// Job handlers 81// Job handlers
73// --------------------------------------------------------------------------- 82// ---------------------------------------------------------------------------
74 83
@@ -119,7 +128,7 @@ async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTrans
119 128
120 logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 129 logger.info('Merge audio transcoding job for %s ended.', video.uuid, lTags(video.uuid))
121 130
122 await onVideoFileOptimizer(video, payload, 'video', user) 131 await onVideoFirstWebTorrentTranscoding(video, payload, 'video', user)
123} 132}
124 133
125async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { 134async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
@@ -129,7 +138,7 @@ async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodi
129 138
130 logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid)) 139 logger.info('Optimize transcoding job for %s ended.', video.uuid, lTags(video.uuid))
131 140
132 await onVideoFileOptimizer(video, payload, transcodeType, user) 141 await onVideoFirstWebTorrentTranscoding(video, payload, transcodeType, user)
133} 142}
134 143
135// --------------------------------------------------------------------------- 144// ---------------------------------------------------------------------------
@@ -159,7 +168,7 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay
159 await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo) 168 await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
160} 169}
161 170
162async function onVideoFileOptimizer ( 171async function onVideoFirstWebTorrentTranscoding (
163 videoArg: MVideoWithFile, 172 videoArg: MVideoWithFile,
164 payload: OptimizeTranscodingPayload | MergeAudioTranscodingPayload, 173 payload: OptimizeTranscodingPayload | MergeAudioTranscodingPayload,
165 transcodeType: TranscodeOptionsType, 174 transcodeType: TranscodeOptionsType,
@@ -211,6 +220,8 @@ async function onNewWebTorrentFileResolution (
211 await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo) 220 await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo)
212} 221}
213 222
223// ---------------------------------------------------------------------------
224
214async function createHlsJobIfEnabled (user: MUserId, payload: { 225async function createHlsJobIfEnabled (user: MUserId, payload: {
215 videoUUID: string 226 videoUUID: string
216 resolution: number 227 resolution: number
@@ -241,16 +252,6 @@ async function createHlsJobIfEnabled (user: MUserId, payload: {
241 return true 252 return true
242} 253}
243 254
244// ---------------------------------------------------------------------------
245
246export {
247 processVideoTranscoding,
248 createHlsJobIfEnabled,
249 onNewWebTorrentFileResolution
250}
251
252// ---------------------------------------------------------------------------
253
254async function createLowerResolutionsJobs (options: { 255async function createLowerResolutionsJobs (options: {
255 video: MVideoFullLight 256 video: MVideoFullLight
256 user: MUserId 257 user: MUserId