Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script printing command to generate a resolution for a given file
- Loading branch information
Showing
3 changed files
with
66 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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('<path>') | ||
.option('-r, --resolution <res>', 'video resolution', '480') | ||
.action((path, cmd) => { | ||
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters