aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/print-transcode-command.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-23 03:38:38 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-01-13 09:13:31 +0100
commit0984960345704c10256b40b78db1e4d9d7527e77 (patch)
tree6cafd4dbfb089bcb3997daa56c5ac55f290ef378 /scripts/print-transcode-command.ts
parent1ea7da819e5bfae7b443ed722c18c4165d101439 (diff)
downloadPeerTube-0984960345704c10256b40b78db1e4d9d7527e77.tar.gz
PeerTube-0984960345704c10256b40b78db1e4d9d7527e77.tar.zst
PeerTube-0984960345704c10256b40b78db1e4d9d7527e77.zip
add script printing command to generate a resolution for a given file
Diffstat (limited to 'scripts/print-transcode-command.ts')
-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}