Add resolution to create-transcoding-job script (#654)
[oweals/peertube.git] / scripts / create-transcoding-job.ts
index 463cdfad39f100a7664f563a216a1c0a5aa160da..179fb4fa6e099642853c044c8d1f687f8e42c8d2 100755 (executable)
@@ -8,6 +8,7 @@ import { JobQueue } from '../server/lib/job-queue'
 
 program
   .option('-v, --video [videoUUID]', 'Video UUID')
+  .option('-r, --resolution [resolution]', 'Video resolution (integer)')
   .parse(process.argv)
 
 if (program['video'] === undefined) {
@@ -15,6 +16,11 @@ if (program['video'] === undefined) {
   process.exit(-1)
 }
 
+if (program.resolution !== undefined && Number.isNaN(+program.resolution)) {
+  console.error('The resolution must be an integer (example: 1080).')
+  process.exit(-1)
+}
+
 run()
   .then(() => process.exit(0))
   .catch(err => {
@@ -30,7 +36,12 @@ async function run () {
 
   const dataInput = {
     videoUUID: video.uuid,
-    isNewVideo: false
+    isNewVideo: false,
+    resolution: undefined
+  }
+
+  if (program.resolution !== undefined) {
+    dataInput.resolution = program.resolution
   }
 
   await JobQueue.Instance.init()