]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/print-transcode-command.ts
Stop using tsconfig register
[github/Chocobozzz/PeerTube.git] / scripts / print-transcode-command.ts
CommitLineData
8cc61201 1import { program } from 'commander'
41fb13c3 2import ffmpeg from 'fluent-ffmpeg'
09849603 3import { exit } from 'process'
f8360396 4import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils'
c07902b9 5import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/video-transcoding-profiles'
09849603
RK
6
7program
8 .arguments('<path>')
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).')
13 process.exit(-1)
14 }
15
16 run(path, cmd)
17 .then(() => process.exit(0))
18 .catch(err => {
19 console.error(err)
20 process.exit(-1)
21 })
22 })
23 .parse(process.argv)
24
25async function run (path: string, cmd: any) {
26 const options = {
27 type: 'video' as 'video',
28 inputPath: path,
29 outputPath: '/dev/null',
30
529b3752 31 availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(),
09849603
RK
32 profile: 'default',
33
34 resolution: +cmd.resolution,
35 isPortraitMode: false
36 } as TranscodeOptions
37
38 let command = ffmpeg(options.inputPath)
39 .output(options.outputPath)
40
41 command = await buildx264VODCommand(command, options)
42
43 command.on('start', (cmdline) => {
44 console.log(cmdline)
45 exit()
46 })
47
cd2c3dcd 48 await runCommand({ command })
09849603 49}