add h264 profile picker

This commit is contained in:
matty 2024-04-15 19:57:26 -04:00
parent f81fa92956
commit 96ececa3f1

29
dist/main.js vendored
View File

@ -9,6 +9,7 @@ const DEFAULT_HEVC_PROFILE = "main";
const DEFAULT_LIVE_QUALITY = "hq";
const DEFAULT_CQ_H264 = 26;
const DEFAULT_CQ_HEVC = 28;
const DEFAULT_H264_PROFILE = "main";
const DEFAULT_BITRATES = new Map([
[0, 64 * 1000],
[144, 320 * 1000],
@ -26,6 +27,7 @@ let pluginSettings = {
hevcProfile: DEFAULT_HEVC_PROFILE,
cqH264: DEFAULT_CQ_H264,
cqHEVC: DEFAULT_CQ_HEVC,
h264Profile: DEFAULT_H264_PROFILE,
baseBitrate: new Map(DEFAULT_BITRATES)
};
let latestStreamNum = 9999;
@ -103,6 +105,19 @@ async function register({ settingsManager, peertubeHelpers, transcodingManager:
default: DEFAULT_HEVC_PROFILE.toString(),
private: false
});
registerSetting({
name: 'h264-profile',
label: 'H264 Profile',
type: 'select',
options: [
{ label: 'main (default)', value: 'main' },
{ label: 'high', value: 'high' },
{ label: 'high444p', value: 'high444p' }
],
descriptionHTML: 'Set the H264 profile',
default: DEFAULT_H264_PROFILE.toString(),
private: false
});
registerSetting({
name: 'live-quality',
label: 'Live Quality',
@ -153,6 +168,7 @@ async function loadSettings(settingsManager) {
pluginSettings.hevcProfile = await settingsManager.getSetting('hevc-profile') || DEFAULT_HEVC_PROFILE;
pluginSettings.cqH264 = parseInt(await settingsManager.getSetting('cq-h264')) || DEFAULT_CQ_H264;
pluginSettings.cqHEVC = parseInt(await settingsManager.getSetting('cq-hevc')) || DEFAULT_CQ_HEVC;
pluginSettings.h264Profile = await settingsManager.getSetting('h264-profile') || DEFAULT_H264_PROFILE;
for (const [resolution, bitrate] of DEFAULT_BITRATES) {
const key = `base-bitrate-${resolution}`;
@ -164,6 +180,7 @@ async function loadSettings(settingsManager) {
logger.info(`VOD Quality: ${pluginSettings.vodQuality}`);
logger.info(`Live Quality: ${pluginSettings.liveQuality}`);
logger.info(`HEVC profile: ${pluginSettings.hevcProfile}`);
logger.info(`H264 profile: ${pluginSettings.h264Profile}`);
}
function printResolution(resolution) {
switch (resolution) {
@ -217,13 +234,13 @@ async function vodBuilder(params) {
`-preset ${pluginSettings.vodQuality}`,
`-b:v${streamSuffix} ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}`,
`-profile:v${streamSuffix} high`,
`-profile:v${streamSuffix} ${pluginSettings.h264Profile}`,
`-cq ${pluginSettings.cqH264}`,
`-bf 4`
]
};
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
logger.info(`EncoderOptions: ${JSON.stringify(options)}, HEVC: false`);
return options;
}
@ -255,7 +272,7 @@ async function hevcVODBuilder(params) {
]
};
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
logger.info(`EncoderOptions: ${JSON.stringify(options)}, HEVC: true`);
return options;
}
@ -292,7 +309,7 @@ async function hevcLiveBuilder(params) {
]
};
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
logger.info(`EncoderOptions: ${JSON.stringify(options)}, HEVC: true`);
return options;
}
@ -320,7 +337,7 @@ async function liveBuilder(params) {
outputOptions: [
`-tune ${pluginSettings.liveQuality}`,
`-r:v${streamSuffix} ${fps}`,
`-profile:v${streamSuffix} high`,
`-profile:v${streamSuffix} ${pluginSettings.h264Profile}`,
`-cq ${pluginSettings.cqH264}`,
`-g:v${streamSuffix} ${fps * 2}`,
`-b:v${streamSuffix} ${targetBitrate}`,
@ -329,7 +346,7 @@ async function liveBuilder(params) {
]
};
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
logger.info(`EncoderOptions: ${JSON.stringify(options)}, HEVC: false`);
return options;
}
function getTargetBitrate(resolution, fps) {