1 import { program } from 'commander'
2 import ffmpeg from 'fluent-ffmpeg'
3 import { exit } from 'process'
4 import { buildVODCommand, runCommand, TranscodeVODOptions } from '@server/helpers/ffmpeg'
5 import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles'
9 .requiredOption('-r, --resolution [resolution]', 'video resolution')
10 .action((path, cmd) => {
11 if (cmd.resolution !== undefined && Number.isNaN(+cmd.resolution)) {
12 console.error('The resolution must be an integer (example: 1080).')
17 .then(() => process.exit(0))
25 async function run (path: string, cmd: any) {
27 type: 'video' as 'video',
29 outputPath: '/dev/null',
31 availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(),
34 resolution: +cmd.resolution
35 } as TranscodeVODOptions
37 let command = ffmpeg(options.inputPath)
38 .output(options.outputPath)
40 command = await buildVODCommand(command, options)
42 command.on('start', (cmdline) => {
47 await runCommand({ command })