fuck it, just go with input bitrate

This commit is contained in:
matty 2024-04-13 19:04:47 -04:00
parent b24c0e4ef7
commit 4b8b0e4888

24
dist/main.js vendored
View File

@ -146,12 +146,12 @@ function buildInitOptions() {
async function vodBuilder(params) { async function vodBuilder(params) {
const { resolution, fps, streamNum, inputBitrate } = params; const { resolution, fps, streamNum, inputBitrate } = params;
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`; const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`;
let targetBitrate = getTargetBitrate(resolution, fps); //let targetBitrate = getTargetBitrate(resolution, fps);
// let targetBitrate = inputBitrate; let targetBitrate = inputBitrate;
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum); let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum);
if (targetBitrate > inputBitrate) { //if (targetBitrate > inputBitrate) {
targetBitrate = inputBitrate; // targetBitrate = inputBitrate;
} //}
logger.info(`Building encoder options, received ${JSON.stringify(params)}`); logger.info(`Building encoder options, received ${JSON.stringify(params)}`);
if (shouldInitVaapi && streamNum != undefined) { if (shouldInitVaapi && streamNum != undefined) {
latestStreamNum = streamNum; latestStreamNum = streamNum;
@ -166,7 +166,7 @@ async function vodBuilder(params) {
`-b:v${streamSuffix} ${targetBitrate}`, `-b:v${streamSuffix} ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}`, `-bufsize ${targetBitrate * 2}`,
`-profile:v${streamSuffix} high`, `-profile:v${streamSuffix} high`,
`-cq 22`, `-cq 24`,
`-c:v${streamSuffix} h264_nvenc` `-c:v${streamSuffix} h264_nvenc`
] ]
}; };
@ -176,12 +176,12 @@ async function vodBuilder(params) {
async function liveBuilder(params) { async function liveBuilder(params) {
const { resolution, fps, streamNum, inputBitrate } = params; const { resolution, fps, streamNum, inputBitrate } = params;
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`; const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`;
let targetBitrate = getTargetBitrate(resolution, fps); // let targetBitrate = getTargetBitrate(resolution, fps);
// let targetBitrate = inputBitrate; let targetBitrate = inputBitrate;
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum); let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum);
if (targetBitrate > inputBitrate) { //if (targetBitrate > inputBitrate) {
targetBitrate = inputBitrate; // targetBitrate = inputBitrate;
} //}
logger.info(`Building encoder options, received ${JSON.stringify(params)}`); logger.info(`Building encoder options, received ${JSON.stringify(params)}`);
if (shouldInitVaapi && streamNum != undefined) { if (shouldInitVaapi && streamNum != undefined) {
latestStreamNum = streamNum; latestStreamNum = streamNum;
@ -196,7 +196,7 @@ async function liveBuilder(params) {
`-r:v${streamSuffix} ${fps}`, `-r:v${streamSuffix} ${fps}`,
`-profile:v${streamSuffix} high`, `-profile:v${streamSuffix} high`,
`-c:v${streamSuffix} h264_nvenc`, `-c:v${streamSuffix} h264_nvenc`,
`-cq 22`, `-cq 24`,
`-g:v${streamSuffix} ${fps * 2}`, `-g:v${streamSuffix} ${fps * 2}`,
`-b:v${streamSuffix} ${targetBitrate}`, `-b:v${streamSuffix} ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}` `-bufsize ${targetBitrate * 2}`