]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/create-transcoding-job.ts
Fix user tests
[github/Chocobozzz/PeerTube.git] / scripts / create-transcoding-job.ts
index 179fb4fa6e099642853c044c8d1f687f8e42c8d2..2b7cb5177e2e4c0ec790a3a97010a81d023baeff 100755 (executable)
@@ -1,10 +1,8 @@
 import * as program from 'commander'
-import { createReadStream } from 'fs'
-import { join } from 'path'
-import { createInterface } from 'readline'
 import { VideoModel } from '../server/models/video/video'
 import { initDatabaseModels } from '../server/initializers'
 import { JobQueue } from '../server/lib/job-queue'
+import { VideoTranscodingPayload } from '../server/lib/job-queue/handlers/video-transcoding'
 
 program
   .option('-v, --video [videoUUID]', 'Video UUID')
@@ -31,20 +29,14 @@ run()
 async function run () {
   await initDatabaseModels(true)
 
-  const video = await VideoModel.loadByUUID(program['video'])
+  const video = await VideoModel.loadByUUIDWithFile(program['video'])
   if (!video) throw new Error('Video not found.')
 
-  const dataInput = {
-    videoUUID: video.uuid,
-    isNewVideo: false,
-    resolution: undefined
-  }
-
-  if (program.resolution !== undefined) {
-    dataInput.resolution = program.resolution
-  }
+  const dataInput: VideoTranscodingPayload = program.resolution !== undefined
+   ? { type: 'new-resolution' as 'new-resolution', videoUUID: video.uuid, isNewVideo: false, resolution: program.resolution }
+   : { type: 'optimize' as 'optimize', videoUUID: video.uuid, isNewVideo: false }
 
   await JobQueue.Instance.init()
-  await JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput })
+  await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput })
   console.log('Transcoding job for video %s created.', video.uuid)
 }