]>
Commit | Line | Data |
---|---|---|
09849603 RK |
1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' |
2 | registerTSPaths() | |
3 | ||
8cc61201 | 4 | import { program } from 'commander' |
09849603 | 5 | import * as ffmpeg from 'fluent-ffmpeg' |
09849603 RK |
6 | import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils' |
7 | import { exit } from 'process' | |
c07902b9 | 8 | import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/video-transcoding-profiles' |
09849603 RK |
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 | ||
529b3752 | 34 | availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(), |
09849603 RK |
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 | ||
cd2c3dcd | 51 | await runCommand({ command }) |
09849603 | 52 | } |