aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/print-transcode-command.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/print-transcode-command.ts b/scripts/print-transcode-command.ts
new file mode 100644
index 000000000..b75b711a4
--- /dev/null
+++ b/scripts/print-transcode-command.ts
@@ -0,0 +1,52 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import * as program from 'commander'
5import * as ffmpeg from 'fluent-ffmpeg'
6import { availableEncoders } from '@server/lib/video-transcoding-profiles'
7import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils'
8import { exit } from 'process'
9
10program
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
28async function run (path: string, cmd: any) {
29 const options = {
30 type: 'video' as 'video',
31 inputPath: path,
32 outputPath: '/dev/null',
33
34 availableEncoders,
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}