aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/video-file.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-30 10:49:40 +0200
committerChocobozzz <me@florianbigard.com>2018-05-30 10:49:56 +0200
commit0c948c1659c0a6010f2bf58c402b1c9af192aa5e (patch)
tree9e82656fc81af435f8d6c139b3decac409fa6aeb /server/lib/job-queue/handlers/video-file.ts
parentb4f8277cb6503bd889654f0e4f364627e9e00af9 (diff)
downloadPeerTube-0c948c1659c0a6010f2bf58c402b1c9af192aa5e.tar.gz
PeerTube-0c948c1659c0a6010f2bf58c402b1c9af192aa5e.tar.zst
PeerTube-0c948c1659c0a6010f2bf58c402b1c9af192aa5e.zip
Add ability to manually run transcoding job
Diffstat (limited to 'server/lib/job-queue/handlers/video-file.ts')
-rw-r--r--server/lib/job-queue/handlers/video-file.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts
index 1b41d29e8..93f9e9fe7 100644
--- a/server/lib/job-queue/handlers/video-file.ts
+++ b/server/lib/job-queue/handlers/video-file.ts
@@ -11,7 +11,8 @@ import { JobQueue } from '../job-queue'
11 11
12export type VideoFilePayload = { 12export type VideoFilePayload = {
13 videoUUID: string 13 videoUUID: string
14 resolution?: VideoResolution, 14 isNewVideo: boolean
15 resolution?: VideoResolution
15 isPortraitMode?: boolean 16 isPortraitMode?: boolean
16} 17}
17 18
@@ -32,7 +33,7 @@ async function processVideoFile (job: kue.Job) {
32 await onVideoFileTranscoderSuccess(video) 33 await onVideoFileTranscoderSuccess(video)
33 } else { 34 } else {
34 await video.optimizeOriginalVideofile() 35 await video.optimizeOriginalVideofile()
35 await onVideoFileOptimizerSuccess(video) 36 await onVideoFileOptimizerSuccess(video, payload.isNewVideo)
36 } 37 }
37 38
38 return video 39 return video
@@ -53,7 +54,7 @@ async function onVideoFileTranscoderSuccess (video: VideoModel) {
53 return undefined 54 return undefined
54} 55}
55 56
56async function onVideoFileOptimizerSuccess (video: VideoModel) { 57async function onVideoFileOptimizerSuccess (video: VideoModel, isNewVideo: boolean) {
57 if (video === undefined) return undefined 58 if (video === undefined) return undefined
58 59
59 // Maybe the video changed in database, refresh it 60 // Maybe the video changed in database, refresh it
@@ -62,11 +63,15 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) {
62 if (!videoDatabase) return undefined 63 if (!videoDatabase) return undefined
63 64
64 if (video.privacy !== VideoPrivacy.PRIVATE) { 65 if (video.privacy !== VideoPrivacy.PRIVATE) {
65 // Now we'll add the video's meta data to our followers 66 if (isNewVideo === true) {
66 await sequelizeTypescript.transaction(async t => { 67 // Now we'll add the video's meta data to our followers
67 await sendCreateVideo(video, t) 68 await sequelizeTypescript.transaction(async t => {
68 await shareVideoByServerAndChannel(video, t) 69 await sendCreateVideo(video, t)
69 }) 70 await shareVideoByServerAndChannel(video, t)
71 })
72 } else {
73 await sendUpdateVideo(video, undefined)
74 }
70 } 75 }
71 76
72 const { videoFileResolution } = await videoDatabase.getOriginalFileResolution() 77 const { videoFileResolution } = await videoDatabase.getOriginalFileResolution()
@@ -84,7 +89,8 @@ async function onVideoFileOptimizerSuccess (video: VideoModel) {
84 for (const resolution of resolutionsEnabled) { 89 for (const resolution of resolutionsEnabled) {
85 const dataInput = { 90 const dataInput = {
86 videoUUID: videoDatabase.uuid, 91 videoUUID: videoDatabase.uuid,
87 resolution 92 resolution,
93 isNewVideo
88 } 94 }
89 95
90 const p = JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput }) 96 const p = JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput })