add script printing command to generate a resolution for a given file
This commit is contained in:
parent
1ea7da819e
commit
0984960345
3 changed files with 71 additions and 16 deletions
|
@ -54,6 +54,7 @@
|
||||||
"update-host": "node ./dist/scripts/update-host.js",
|
"update-host": "node ./dist/scripts/update-host.js",
|
||||||
"create-transcoding-job": "node ./dist/scripts/create-transcoding-job.js",
|
"create-transcoding-job": "node ./dist/scripts/create-transcoding-job.js",
|
||||||
"create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js",
|
"create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js",
|
||||||
|
"print-transcode-command": "node ./dist/scripts/print-transcode-command.js",
|
||||||
"test": "scripty",
|
"test": "scripty",
|
||||||
"help": "scripty",
|
"help": "scripty",
|
||||||
"generate-cli-doc": "scripty",
|
"generate-cli-doc": "scripty",
|
||||||
|
|
52
scripts/print-transcode-command.ts
Normal file
52
scripts/print-transcode-command.ts
Normal file
|
@ -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('<path>')
|
||||||
|
.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)
|
||||||
|
}
|
|
@ -311,22 +311,6 @@ function buildStreamSuffix (base: string, streamNum?: number) {
|
||||||
return base
|
return base
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export {
|
|
||||||
getLiveTranscodingCommand,
|
|
||||||
getLiveMuxingCommand,
|
|
||||||
buildStreamSuffix,
|
|
||||||
convertWebPToJPG,
|
|
||||||
processGIF,
|
|
||||||
generateImageFromVideoFile,
|
|
||||||
TranscodeOptions,
|
|
||||||
TranscodeOptionsType,
|
|
||||||
transcode
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Default options
|
// Default options
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -642,3 +626,21 @@ async function runCommand (command: ffmpeg.FfmpegCommand, onEnd?: Function) {
|
||||||
command.run()
|
command.run()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export {
|
||||||
|
getLiveTranscodingCommand,
|
||||||
|
getLiveMuxingCommand,
|
||||||
|
buildStreamSuffix,
|
||||||
|
convertWebPToJPG,
|
||||||
|
processGIF,
|
||||||
|
generateImageFromVideoFile,
|
||||||
|
TranscodeOptions,
|
||||||
|
TranscodeOptionsType,
|
||||||
|
transcode,
|
||||||
|
runCommand,
|
||||||
|
|
||||||
|
// builders
|
||||||
|
buildx264VODCommand
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue