addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i })
logger.debug(
- 'Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile, builderResult,
- { fps: resolutionFPS, resolution, ...lTags() }
+ 'Apply ffmpeg live video params from %s using %s profile.', builderResult.encoder, profile,
+ { builderResult, fps: resolutionFPS, resolution, ...lTags() }
)
command.outputOption(`${buildStreamSuffix('-c:v', i)} ${builderResult.encoder}`)
addDefaultEncoderParams({ command, encoder: builderResult.encoder, fps: resolutionFPS, streamNum: i })
logger.debug(
- 'Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile, builderResult,
- { fps: resolutionFPS, resolution, ...lTags() }
+ 'Apply ffmpeg live audio params from %s using %s profile.', builderResult.encoder, profile,
+ { builderResult, fps: resolutionFPS, resolution, ...lTags() }
)
command.outputOption(`${buildStreamSuffix('-c:a', i)} ${builderResult.encoder}`)
command.outputOption('-max_muxing_queue_size 1024')
// strip all metadata
.outputOption('-map_metadata -1')
- // NOTE: b-strategy 1 - heuristic algorithm, 16 is optimal B-frames for it
- .outputOption('-b_strategy 1')
- // NOTE: Why 16: https://github.com/Chocobozzz/PeerTube/pull/774. b-strategy 2 -> B-frames<16
- .outputOption('-bf 16')
// allows import of source material with incompatible pixel formats (e.g. MJPEG video)
.outputOption('-pix_fmt yuv420p')
}
logger.debug(
'Apply ffmpeg params from %s for %s stream of input %s using %s profile.',
- builderResult.encoder, streamType, input, profile, builderResult,
- { resolution, fps, ...lTags() }
+ builderResult.encoder, streamType, input, profile,
+ { builderResult, resolution, fps, ...lTags() }
)
if (streamType === 'video') {
command.on('start', cmdline => { shellCommand = cmdline })
command.on('error', (err, stdout, stderr) => {
- if (silent !== true) logger.error('Error in ffmpeg.', { stdout, stderr, ...lTags() })
+ if (silent !== true) logger.error('Error in ffmpeg.', { stdout, stderr, shellCommand, ...lTags() })
rej(err)
})
return {
outputOptions: [
- `-preset veryfast`,
- `-r ${fps}`,
- `-maxrate ${targetBitrate}`,
- `-bufsize ${targetBitrate * 2}`
+ ...getCommonOutputOptions(targetBitrate),
+
+ `-r ${fps}`
]
}
}
return {
outputOptions: [
- `-preset veryfast`,
+ ...getCommonOutputOptions(targetBitrate),
+
`${buildStreamSuffix('-r:v', streamNum)} ${fps}`,
- `${buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`,
- `-maxrate ${targetBitrate}`,
- `-bufsize ${targetBitrate * 2}`
+ `${buildStreamSuffix('-b:v', streamNum)} ${targetBitrate}`
]
}
}
return Math.min(targetBitrate, inputBitrateWithMargin)
}
+
+function getCommonOutputOptions (targetBitrate: number) {
+ return [
+ `-preset veryfast`,
+ `-maxrate ${targetBitrate}`,
+ `-bufsize ${targetBitrate * 2}`,
+
+ // NOTE: b-strategy 1 - heuristic algorithm, 16 is optimal B-frames for it
+ `-b_strategy 1`,
+ // NOTE: Why 16: https://github.com/Chocobozzz/PeerTube/pull/774. b-strategy 2 -> B-frames<16
+ `-bf 16`
+ ]
+}