aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-transcoding.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-04-21 16:31:04 +0200
committerChocobozzz <chocobozzz@cpy.re>2023-05-09 08:57:34 +0200
commitcc2abbc320ea66296bf45314a2efb47d16b38374 (patch)
tree488882ef5752d790f9e16800fb76dd3dd3cb6a7b /server/lib/job-queue/handlers/video-transcoding.ts
parent1772b383de490cf406fe93ef3aa3a941f6db513c (diff)
downloadPeerTube-cc2abbc320ea66296bf45314a2efb47d16b38374.tar.gz
PeerTube-cc2abbc320ea66296bf45314a2efb47d16b38374.tar.zst
PeerTube-cc2abbc320ea66296bf45314a2efb47d16b38374.zip
Fix next video state after optimize/audio merge
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, 16 insertions, 11 deletions
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 17b717275..39f078bf0 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -81,7 +81,7 @@ async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTrans
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))
83 83
84 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, 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) {
@@ -91,9 +91,11 @@ async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodi
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))
93 93
94 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video }) 94 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video })
95} 95}
96 96
97// ---------------------------------------------------------------------------
98
97async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorrentResolutionTranscodingPayload, video: MVideoFullLight) { 99async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorrentResolutionTranscodingPayload, video: MVideoFullLight) {
98 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))
99 101
@@ -104,19 +106,22 @@ async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorren
104 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video }) 106 await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video })
105} 107}
106 108
107async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MVideoFullLight) { 109// ---------------------------------------------------------------------------
108 logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid))
109
110 const videoFileInput = payload.copyCodecs
111 ? video.getWebTorrentFile(payload.resolution)
112 : video.getMaxQualityFile()
113 110
114 const videoOrStreamingPlaylist = videoFileInput.getVideoOrStreamingPlaylist() 111async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: MVideoFullLight) {
112 logger.info('Handling HLS transcoding job for %s.', videoArg.uuid, lTags(videoArg.uuid))
115 113
116 const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid) 114 const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(videoArg.uuid)
115 let video: MVideoFullLight
117 116
118 try { 117 try {
119 await videoFileInput.getVideo().reload() 118 video = await VideoModel.loadFull(videoArg.uuid)
119
120 const videoFileInput = payload.copyCodecs
121 ? video.getWebTorrentFile(payload.resolution)
122 : video.getMaxQualityFile()
123
124 const videoOrStreamingPlaylist = videoFileInput.getVideoOrStreamingPlaylist()
120 125
121 await VideoPathManager.Instance.makeAvailableVideoFile(videoFileInput.withVideoOrPlaylist(videoOrStreamingPlaylist), videoInputPath => { 126 await VideoPathManager.Instance.makeAvailableVideoFile(videoFileInput.withVideoOrPlaylist(videoOrStreamingPlaylist), videoInputPath => {
122 return generateHlsPlaylistResolution({ 127 return generateHlsPlaylistResolution({