add ability to do that young -cq shit nigga

This commit is contained in:
matty 2024-04-14 16:12:26 -04:00
parent 7761d12bc8
commit 7314c18ca4

29
dist/main.js vendored
View File

@ -8,6 +8,8 @@ const DEFAULT_VOD_QUALITY = "p7";
const DEFAULT_HEVC_PROFILE = "main10";
const DEFAULT_LIVE_QUALITY = "hq";
const DEFAULT_HEVC_ENABLED = false;
const DEFAULT_CQ_H264 = 26;
const DEFAULT_CQ_HEVC = 28;
const DEFAULT_BITRATES = new Map([
[0, 64 * 1000],
[144, 320 * 1000],
@ -24,6 +26,8 @@ let pluginSettings = {
liveQuality: DEFAULT_LIVE_QUALITY,
hevcEnabled: DEFAULT_HEVC_ENABLED,
hevcProfile: DEFAULT_HEVC_PROFILE,
cqH264: DEFAULT_CQ_H264,
cqHEVC: DEFAULT_CQ_HEVC,
baseBitrate: new Map(DEFAULT_BITRATES)
};
let latestStreamNum = 9999;
@ -63,6 +67,22 @@ async function register({ settingsManager, peertubeHelpers, transcodingManager:
default: DEFAULT_HEVC_ENABLED,
private: false
});
registerSetting({
name: 'cq-h264',
label: 'CQ Value for H264_nvenc',
type: 'input',
descriptionHTML: 'Sets the -cq value for h264_nvenc encoder. Valid values are between 0 and 51 (lossess and AIDS, respectively)',
default: DEFAULT_CQ_H264,
private: false
});
registerSetting({
name: 'cq-hevc',
label: 'CQ Value for hevc_nvenc',
type: 'input',
descriptionHTML: 'Sets the -cq value for hevc_nvenc encoder. Valid values are between 0 and 51 (lossess and AIDS, respectively)',
default: DEFAULT_CQ_HEVC,
private: false
});
registerSetting({
name: 'vod-quality',
label: 'VOD Quality',
@ -142,6 +162,9 @@ async function loadSettings(settingsManager) {
pluginSettings.liveQuality = parseInt(await settingsManager.getSetting('live-quality')) || DEFAULT_LIVE_QUALITY;
pluginSettings.hevcProfile = parseInt(await settingsManager.getSetting('hevc-profile')) || DEFAULT_HEVC_PROFILE;
pluginSettings.hevcEnabled = await settingsManager.getSetting('hevc-enabled') || DEFAULT_HEVC_ENABLED;
pluginSettings.cqH264 = parseInt(await settingsManager.getSetting('cq-h264')) || DEFAULT_CQ_H264;
pluginSettings.cqHEVC = parseInt(await settingsManager.getSetting('cq-hevc')) || DEFAULT_CQ_HEVC;
for (const [resolution, bitrate] of DEFAULT_BITRATES) {
const key = `base-bitrate-${resolution}`;
const storedValue = await settingsManager.getSetting(key);
@ -207,7 +230,7 @@ async function vodBuilder(params) {
`-b:v${streamSuffix} ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}`,
`-profile:v${streamSuffix} high`,
`-cq 25`,
`-cq ${pluginSettings.cqH264}`,
`-bf 4`
]
};
@ -240,6 +263,7 @@ async function hevcVODBuilder(params) {
`-b:v${streamSuffix} ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}`,
`-profile:v${streamSuffix} ${pluginSettings.hevcProfile}`,
`-cq ${pluginSettings.cqHEVC}`
]
};
@ -275,6 +299,7 @@ async function hevcLiveBuilder(params) {
`-profile:v${streamSuffix} ${pluginSettings.hevcProfile}`,
`-g:v${streamSuffix} ${fps * 2}`,
`-b:v${streamSuffix} ${targetBitrate}`,
`-cq ${pluginSettings.cqHEVC}`,
`-bufsize ${targetBitrate * 2}`
]
};
@ -308,7 +333,7 @@ async function liveBuilder(params) {
`-tune ${pluginSettings.liveQuality}`,
`-r:v${streamSuffix} ${fps}`,
`-profile:v${streamSuffix} high`,
`-cq 25`,
`-cq ${pluginSettings.cqH264}`,
`-g:v${streamSuffix} ${fps * 2}`,
`-b:v${streamSuffix} ${targetBitrate}`,
`-bufsize ${targetBitrate * 2}`,