add support for inputOptions in trancode plugins

This commit is contained in:
Théo Le Calvar 2021-04-03 18:48:14 +02:00 committed by Chocobozzz
parent d2466f0ac9
commit 5fb7cfbac5
4 changed files with 13 additions and 5 deletions

View File

@ -277,6 +277,7 @@ async function getLiveTranscodingCommand (options: {
logger.debug('Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult) logger.debug('Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult)
command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`) command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`)
command.addInputOptions(builderResult.result.inputOptions)
command.addOutputOptions(builderResult.result.outputOptions) command.addOutputOptions(builderResult.result.outputOptions)
} }
@ -294,6 +295,7 @@ async function getLiveTranscodingCommand (options: {
logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult) logger.debug('Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult)
command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`) command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`)
command.addInputOptions(builderResult.result.inputOptions)
command.addOutputOptions(builderResult.result.outputOptions) command.addOutputOptions(builderResult.result.outputOptions)
} }
@ -605,6 +607,7 @@ async function presetVideo (
localCommand.audioCodec(builderResult.encoder) localCommand.audioCodec(builderResult.encoder)
} }
command.addInputOptions(builderResult.result.inputOptions)
command.addOutputOptions(builderResult.result.outputOptions) command.addOutputOptions(builderResult.result.outputOptions)
addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps }) addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps })
} }

View File

@ -24,9 +24,10 @@ import { VIDEO_TRANSCODING_FPS } from '../initializers/constants'
const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = async ({ input, resolution, fps }) => { const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = async ({ input, resolution, fps }) => {
const targetBitrate = await buildTargetBitrate({ input, resolution, fps }) const targetBitrate = await buildTargetBitrate({ input, resolution, fps })
if (!targetBitrate) return { outputOptions: [ ] } if (!targetBitrate) return { inputOptions: [ ], outputOptions: [ ] }
return { return {
inputOptions: [ ],
outputOptions: [ outputOptions: [
`-preset veryfast`, `-preset veryfast`,
`-r ${fps}`, `-r ${fps}`,
@ -40,6 +41,7 @@ const defaultX264LiveOptionsBuilder: EncoderOptionsBuilder = async ({ resolution
const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS) const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)
return { return {
inputOptions: [ ],
outputOptions: [ outputOptions: [
`-preset veryfast`, `-preset veryfast`,
`${buildStreamSuffix('-r:v', streamNum)} ${fps}`, `${buildStreamSuffix('-r:v', streamNum)} ${fps}`,
@ -55,7 +57,7 @@ const defaultAACOptionsBuilder: EncoderOptionsBuilder = async ({ input, streamNu
if (await canDoQuickAudioTranscode(input, probe)) { if (await canDoQuickAudioTranscode(input, probe)) {
logger.debug('Copy audio stream %s by AAC encoder.', input) logger.debug('Copy audio stream %s by AAC encoder.', input)
return { copy: true, outputOptions: [] } return { copy: true, inputOptions: [ ], outputOptions: [ ] }
} }
const parsedAudio = await getAudioStream(input, probe) const parsedAudio = await getAudioStream(input, probe)
@ -70,14 +72,14 @@ const defaultAACOptionsBuilder: EncoderOptionsBuilder = async ({ input, streamNu
logger.debug('Calculating audio bitrate of %s by AAC encoder.', input, { bitrate: parsedAudio.bitrate, audioCodecName }) logger.debug('Calculating audio bitrate of %s by AAC encoder.', input, { bitrate: parsedAudio.bitrate, audioCodecName })
if (bitrate !== undefined && bitrate !== -1) { if (bitrate !== undefined && bitrate !== -1) {
return { outputOptions: [ buildStreamSuffix('-b:a', streamNum), bitrate + 'k' ] } return { inputOptions: [ ], outputOptions: [ buildStreamSuffix('-b:a', streamNum), bitrate + 'k' ] }
} }
return { outputOptions: [ ] } return { inputOptions: [ ], outputOptions: [ ] }
} }
const defaultLibFDKAACVODOptionsBuilder: EncoderOptionsBuilder = ({ streamNum }) => { const defaultLibFDKAACVODOptionsBuilder: EncoderOptionsBuilder = ({ streamNum }) => {
return { outputOptions: [ buildStreamSuffix('-q:a', streamNum), '5' ] } return { inputOptions: [ ], outputOptions: [ buildStreamSuffix('-q:a', streamNum), '5' ] }
} }
// Used to get and update available encoders // Used to get and update available encoders

View File

@ -12,6 +12,7 @@ export type EncoderOptionsBuilder = (params: {
export interface EncoderOptions { export interface EncoderOptions {
copy?: boolean // Copy stream? Default to false copy?: boolean // Copy stream? Default to false
inputOptions: string[]
outputOptions: string[] outputOptions: string[]
} }

View File

@ -342,6 +342,7 @@ async function register ({
// You can also return a promise // You can also return a promise
return { return {
inputOptions: [],
outputOptions: [ outputOptions: [
// Use a custom bitrate // Use a custom bitrate
'-b' + streamString + ' 10K' '-b' + streamString + ' 10K'
@ -392,6 +393,7 @@ async function register ({
{ {
const builder = () => { const builder = () => {
return { return {
inputOptions: [],
outputOptions: [] outputOptions: []
} }
} }