1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import { program } from 'commander'
import ffmpeg from 'fluent-ffmpeg'
import { exit } from 'process'
import { buildVODCommand, runCommand, TranscodeVODOptions } from '@server/helpers/ffmpeg'
import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles'
program
.arguments('<path>')
.requiredOption('-r, --resolution [resolution]', 'video resolution')
.action((path, cmd) => {
if (cmd.resolution !== undefined && Number.isNaN(+cmd.resolution)) {
console.error('The resolution must be an integer (example: 1080).')
process.exit(-1)
}
run(path, cmd)
.then(() => process.exit(0))
.catch(err => {
console.error(err)
process.exit(-1)
})
})
.parse(process.argv)
async function run (path: string, cmd: any) {
const options = {
type: 'video' as 'video',
inputPath: path,
outputPath: '/dev/null',
availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(),
profile: 'default',
resolution: +cmd.resolution,
isPortraitMode: false
} as TranscodeVODOptions
let command = ffmpeg(options.inputPath)
.output(options.outputPath)
command = await buildVODCommand(command, options)
command.on('start', (cmdline) => {
console.log(cmdline)
exit()
})
await runCommand({ command })
}
|