set bitrate to input if lower than target bitrate

This commit is contained in:
Théo Le Calvar 2023-05-13 14:12:15 +02:00
parent b254ee282d
commit 044975b376

View File

@ -165,11 +165,15 @@ function buildInitOptions() {
}
async function vodBuilder(params: EncoderOptionsBuilderParams) : Promise<EncoderOptions> {
const { resolution, fps, streamNum } = params
const { resolution, fps, streamNum, inputBitrate } = params
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`
const targetBitrate = getTargetBitrate(resolution, fps)
let targetBitrate = getTargetBitrate(resolution, fps)
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum)
if (targetBitrate > inputBitrate) {
targetBitrate = inputBitrate
}
logger.info(`Building encoder options, received ${JSON.stringify(params)}`)
if (shouldInitVaapi && streamNum != undefined) {
@ -194,11 +198,15 @@ async function vodBuilder(params: EncoderOptionsBuilderParams) : Promise<Encoder
async function liveBuilder(params: EncoderOptionsBuilderParams) : Promise<EncoderOptions> {
const { resolution, fps, streamNum } = params
const { resolution, fps, streamNum, inputBitrate } = params
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`
const targetBitrate = getTargetBitrate(resolution, fps)
let targetBitrate = getTargetBitrate(resolution, fps)
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum)
if (targetBitrate > inputBitrate) {
targetBitrate = inputBitrate
}
logger.info(`Building encoder options, received ${JSON.stringify(params)}`)
if (shouldInitVaapi && streamNum != undefined) {