aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/jobs/handlers/video-file-optimizer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/jobs/handlers/video-file-optimizer.ts')
-rw-r--r--server/lib/jobs/handlers/video-file-optimizer.ts15
1 files changed, 10 insertions, 5 deletions
diff --git a/server/lib/jobs/handlers/video-file-optimizer.ts b/server/lib/jobs/handlers/video-file-optimizer.ts
index 799ba8b01..ccded4721 100644
--- a/server/lib/jobs/handlers/video-file-optimizer.ts
+++ b/server/lib/jobs/handlers/video-file-optimizer.ts
@@ -29,17 +29,22 @@ async function onSuccess (jobId: number, video: VideoInstance) {
29 29
30 logger.info('Job %d is a success.', jobId) 30 logger.info('Job %d is a success.', jobId)
31 31
32 const remoteVideo = await video.toAddRemoteJSON() 32 // Maybe the video changed in database, refresh it
33 const videoDatabase = await db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(video.uuid)
34 // Video does not exist anymore
35 if (!videoDatabase) return undefined
36
37 const remoteVideo = await videoDatabase.toAddRemoteJSON()
33 38
34 // Now we'll add the video's meta data to our friends 39 // Now we'll add the video's meta data to our friends
35 await addVideoToFriends(remoteVideo, null) 40 await addVideoToFriends(remoteVideo, null)
36 41
37 const originalFileHeight = await video.getOriginalFileHeight() 42 const originalFileHeight = await videoDatabase.getOriginalFileHeight()
38 // Create transcoding jobs if there are enabled resolutions 43 // Create transcoding jobs if there are enabled resolutions
39 44
40 const resolutionsEnabled = computeResolutionsToTranscode(originalFileHeight) 45 const resolutionsEnabled = computeResolutionsToTranscode(originalFileHeight)
41 logger.info( 46 logger.info(
42 'Resolutions computed for video %s and origin file height of %d.', video.uuid, originalFileHeight, 47 'Resolutions computed for video %s and origin file height of %d.', videoDatabase.uuid, originalFileHeight,
43 { resolutions: resolutionsEnabled } 48 { resolutions: resolutionsEnabled }
44 ) 49 )
45 50
@@ -50,7 +55,7 @@ async function onSuccess (jobId: number, video: VideoInstance) {
50 55
51 for (const resolution of resolutionsEnabled) { 56 for (const resolution of resolutionsEnabled) {
52 const dataInput = { 57 const dataInput = {
53 videoUUID: video.uuid, 58 videoUUID: videoDatabase.uuid,
54 resolution 59 resolution
55 } 60 }
56 61
@@ -61,7 +66,7 @@ async function onSuccess (jobId: number, video: VideoInstance) {
61 await Promise.all(tasks) 66 await Promise.all(tasks)
62 }) 67 })
63 68
64 logger.info('Transcoding jobs created for uuid %s.', video.uuid, { resolutionsEnabled }) 69 logger.info('Transcoding jobs created for uuid %s.', videoDatabase.uuid, { resolutionsEnabled })
65 } catch (err) { 70 } catch (err) {
66 logger.warn('Cannot transcode the video.', err) 71 logger.warn('Cannot transcode the video.', err)
67 } 72 }