diff options
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/transcoding-job-builder.ts | 2 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 27 |
2 files changed, 17 insertions, 12 deletions
diff --git a/server/lib/job-queue/handlers/transcoding-job-builder.ts b/server/lib/job-queue/handlers/transcoding-job-builder.ts index 8b4a877d7..cb45337df 100644 --- a/server/lib/job-queue/handlers/transcoding-job-builder.ts +++ b/server/lib/job-queue/handlers/transcoding-job-builder.ts | |||
@@ -36,7 +36,7 @@ async function processTranscodingJobBuilder (job: Job) { | |||
36 | for (const sequentialJobs of (payload.sequentialJobs || [])) { | 36 | for (const sequentialJobs of (payload.sequentialJobs || [])) { |
37 | await JobQueue.Instance.createSequentialJobFlow(...sequentialJobs) | 37 | await JobQueue.Instance.createSequentialJobFlow(...sequentialJobs) |
38 | 38 | ||
39 | await VideoJobInfoModel.increaseOrCreate(payload.videoUUID, 'pendingTranscode', sequentialJobs.length) | 39 | await VideoJobInfoModel.increaseOrCreate(payload.videoUUID, 'pendingTranscode', sequentialJobs.filter(s => !!s).length) |
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
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 | ||
87 | async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { | 87 | async 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 | |||
97 | async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorrentResolutionTranscodingPayload, video: MVideoFullLight) { | 99 | async 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 | ||
107 | async 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() | 111 | async 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({ |