From 0984960345704c10256b40b78db1e4d9d7527e77 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Wed, 23 Dec 2020 03:38:38 +0100 Subject: add script printing command to generate a resolution for a given file --- scripts/print-transcode-command.ts | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 scripts/print-transcode-command.ts (limited to 'scripts') 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 @@ +import { registerTSPaths } from '../server/helpers/register-ts-paths' +registerTSPaths() + +import * as program from 'commander' +import * as ffmpeg from 'fluent-ffmpeg' +import { availableEncoders } from '@server/lib/video-transcoding-profiles' +import { buildx264VODCommand, runCommand, TranscodeOptions } from '@server/helpers/ffmpeg-utils' +import { exit } from 'process' + +program + .arguments('') + .requiredOption('-r, --resolution [resolution]', 'video resolution') + .action((path, cmd) => { + if (cmd.resolution !== undefined && Number.isNaN(+cmd.resolution)) { + console.error('The resolution must be an integer (example: 1080).') + process.exit(-1) + } + + run(path, cmd) + .then(() => process.exit(0)) + .catch(err => { + console.error(err) + process.exit(-1) + }) + }) + .parse(process.argv) + +async function run (path: string, cmd: any) { + const options = { + type: 'video' as 'video', + inputPath: path, + outputPath: '/dev/null', + + availableEncoders, + profile: 'default', + + resolution: +cmd.resolution, + isPortraitMode: false + } as TranscodeOptions + + let command = ffmpeg(options.inputPath) + .output(options.outputPath) + + command = await buildx264VODCommand(command, options) + + command.on('start', (cmdline) => { + console.log(cmdline) + exit() + }) + + await runCommand(command) +} -- cgit v1.2.3