mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-28 03:23:57 -06:00
add support for inputOptions in trancode plugins
This commit is contained in:
parent
d2466f0ac9
commit
5fb7cfbac5
@ -277,6 +277,7 @@ async function getLiveTranscodingCommand (options: {
|
||||
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.addInputOptions(builderResult.result.inputOptions)
|
||||
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)
|
||||
|
||||
command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`)
|
||||
command.addInputOptions(builderResult.result.inputOptions)
|
||||
command.addOutputOptions(builderResult.result.outputOptions)
|
||||
}
|
||||
|
||||
@ -605,6 +607,7 @@ async function presetVideo (
|
||||
localCommand.audioCodec(builderResult.encoder)
|
||||
}
|
||||
|
||||
command.addInputOptions(builderResult.result.inputOptions)
|
||||
command.addOutputOptions(builderResult.result.outputOptions)
|
||||
addDefaultEncoderParams({ command: localCommand, encoder: builderResult.encoder, fps })
|
||||
}
|
||||
|
@ -24,9 +24,10 @@ import { VIDEO_TRANSCODING_FPS } from '../initializers/constants'
|
||||
|
||||
const defaultX264VODOptionsBuilder: EncoderOptionsBuilder = async ({ input, resolution, fps }) => {
|
||||
const targetBitrate = await buildTargetBitrate({ input, resolution, fps })
|
||||
if (!targetBitrate) return { outputOptions: [ ] }
|
||||
if (!targetBitrate) return { inputOptions: [ ], outputOptions: [ ] }
|
||||
|
||||
return {
|
||||
inputOptions: [ ],
|
||||
outputOptions: [
|
||||
`-preset veryfast`,
|
||||
`-r ${fps}`,
|
||||
@ -40,6 +41,7 @@ const defaultX264LiveOptionsBuilder: EncoderOptionsBuilder = async ({ resolution
|
||||
const targetBitrate = getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS)
|
||||
|
||||
return {
|
||||
inputOptions: [ ],
|
||||
outputOptions: [
|
||||
`-preset veryfast`,
|
||||
`${buildStreamSuffix('-r:v', streamNum)} ${fps}`,
|
||||
@ -55,7 +57,7 @@ const defaultAACOptionsBuilder: EncoderOptionsBuilder = async ({ input, streamNu
|
||||
|
||||
if (await canDoQuickAudioTranscode(input, probe)) {
|
||||
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)
|
||||
@ -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 })
|
||||
|
||||
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 }) => {
|
||||
return { outputOptions: [ buildStreamSuffix('-q:a', streamNum), '5' ] }
|
||||
return { inputOptions: [ ], outputOptions: [ buildStreamSuffix('-q:a', streamNum), '5' ] }
|
||||
}
|
||||
|
||||
// Used to get and update available encoders
|
||||
|
@ -12,6 +12,7 @@ export type EncoderOptionsBuilder = (params: {
|
||||
export interface EncoderOptions {
|
||||
copy?: boolean // Copy stream? Default to false
|
||||
|
||||
inputOptions: string[]
|
||||
outputOptions: string[]
|
||||
}
|
||||
|
||||
|
@ -342,6 +342,7 @@ async function register ({
|
||||
|
||||
// You can also return a promise
|
||||
return {
|
||||
inputOptions: [],
|
||||
outputOptions: [
|
||||
// Use a custom bitrate
|
||||
'-b' + streamString + ' 10K'
|
||||
@ -392,6 +393,7 @@ async function register ({
|
||||
{
|
||||
const builder = () => {
|
||||
return {
|
||||
inputOptions: [],
|
||||
outputOptions: []
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user