aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/create-transcoding-job.ts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/create-transcoding-job.ts')
-rwxr-xr-xscripts/create-transcoding-job.ts18
1 files changed, 10 insertions, 8 deletions
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts
index ca9e2a99a..eb620aeca 100755
--- a/scripts/create-transcoding-job.ts
+++ b/scripts/create-transcoding-job.ts
@@ -14,12 +14,14 @@ program
14 .option('--generate-hls', 'Generate HLS playlist') 14 .option('--generate-hls', 'Generate HLS playlist')
15 .parse(process.argv) 15 .parse(process.argv)
16 16
17if (program['video'] === undefined) { 17const options = program.opts()
18
19if (options.video === undefined) {
18 console.error('All parameters are mandatory.') 20 console.error('All parameters are mandatory.')
19 process.exit(-1) 21 process.exit(-1)
20} 22}
21 23
22if (program.resolution !== undefined && Number.isNaN(+program.resolution)) { 24if (options.resolution !== undefined && Number.isNaN(+options.resolution)) {
23 console.error('The resolution must be an integer (example: 1080).') 25 console.error('The resolution must be an integer (example: 1080).')
24 process.exit(-1) 26 process.exit(-1)
25} 27}
@@ -34,15 +36,15 @@ run()
34async function run () { 36async function run () {
35 await initDatabaseModels(true) 37 await initDatabaseModels(true)
36 38
37 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(program['video']) 39 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.video)
38 if (!video) throw new Error('Video not found.') 40 if (!video) throw new Error('Video not found.')
39 41
40 const dataInput: VideoTranscodingPayload[] = [] 42 const dataInput: VideoTranscodingPayload[] = []
41 const { videoFileResolution } = await video.getMaxQualityResolution() 43 const { videoFileResolution } = await video.getMaxQualityResolution()
42 44
43 if (program.generateHls) { 45 if (options.generateHls) {
44 const resolutionsEnabled = program.resolution 46 const resolutionsEnabled = options.resolution
45 ? [ program.resolution ] 47 ? [ options.resolution ]
46 : computeResolutionsToTranscode(videoFileResolution, 'vod').concat([ videoFileResolution ]) 48 : computeResolutionsToTranscode(videoFileResolution, 'vod').concat([ videoFileResolution ])
47 49
48 for (const resolution of resolutionsEnabled) { 50 for (const resolution of resolutionsEnabled) {
@@ -54,12 +56,12 @@ async function run () {
54 copyCodecs: false 56 copyCodecs: false
55 }) 57 })
56 } 58 }
57 } else if (program.resolution !== undefined) { 59 } else if (options.resolution !== undefined) {
58 dataInput.push({ 60 dataInput.push({
59 type: 'new-resolution-to-webtorrent', 61 type: 'new-resolution-to-webtorrent',
60 videoUUID: video.uuid, 62 videoUUID: video.uuid,
61 isNewVideo: false, 63 isNewVideo: false,
62 resolution: program.resolution 64 resolution: options.resolution
63 }) 65 })
64 } else { 66 } else {
65 dataInput.push({ 67 dataInput.push({