1 import * as program from 'commander'
2 import { VideoModel } from '../server/models/video/video'
3 import { initDatabaseModels } from '../server/initializers'
4 import { JobQueue } from '../server/lib/job-queue'
7 .option('-v, --video [videoUUID]', 'Video UUID')
8 .option('-r, --resolution [resolution]', 'Video resolution (integer)')
11 if (program['video'] === undefined) {
12 console.error('All parameters are mandatory.')
16 if (program.resolution !== undefined && Number.isNaN(+program.resolution)) {
17 console.error('The resolution must be an integer (example: 1080).')
22 .then(() => process.exit(0))
28 async function run () {
29 await initDatabaseModels(true)
31 const video = await VideoModel.loadByUUIDWithFile(program['video'])
32 if (!video) throw new Error('Video not found.')
35 videoUUID: video.uuid,
40 if (program.resolution !== undefined) {
41 dataInput.resolution = program.resolution
44 await JobQueue.Instance.init()
45 await JobQueue.Instance.createJob({ type: 'video-transcoding', payload: dataInput })
46 console.log('Transcoding job for video %s created.', video.uuid)