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