aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/create-transcoding-job.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-03 09:33:05 +0100
committerChocobozzz <me@florianbigard.com>2021-02-03 09:45:08 +0100
commitba5a8d89bbf049e4afc41543bcc072cccdb02669 (patch)
tree6cc6b2dca17745cc0824c7ad4515f3bc4883fa4a /scripts/create-transcoding-job.ts
parent29f148a61381727a432c22a71c7a2b7cc23d9c9e (diff)
downloadPeerTube-ba5a8d89bbf049e4afc41543bcc072cccdb02669.tar.gz
PeerTube-ba5a8d89bbf049e4afc41543bcc072cccdb02669.tar.zst
PeerTube-ba5a8d89bbf049e4afc41543bcc072cccdb02669.zip
Update server dependencies
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({