add basic settings for hevc_nvenc
This commit is contained in:
parent
d82f43cea5
commit
17eafa8872
86
dist/main.js
vendored
86
dist/main.js
vendored
@ -5,7 +5,9 @@ let logger;
|
|||||||
let transcodingManager;
|
let transcodingManager;
|
||||||
const DEFAULT_HARDWARE_DECODE = false;
|
const DEFAULT_HARDWARE_DECODE = false;
|
||||||
const DEFAULT_VOD_QUALITY = "p7";
|
const DEFAULT_VOD_QUALITY = "p7";
|
||||||
|
const DEFAULT_HEVC_PROFILE = "main10";
|
||||||
const DEFAULT_LIVE_QUALITY = "hq";
|
const DEFAULT_LIVE_QUALITY = "hq";
|
||||||
|
const DEFAULT_HEVC_ENABLED = false;
|
||||||
const DEFAULT_BITRATES = new Map([
|
const DEFAULT_BITRATES = new Map([
|
||||||
[0, 64 * 1000],
|
[0, 64 * 1000],
|
||||||
[144, 320 * 1000],
|
[144, 320 * 1000],
|
||||||
@ -20,6 +22,8 @@ let pluginSettings = {
|
|||||||
hardwareDecode: DEFAULT_HARDWARE_DECODE,
|
hardwareDecode: DEFAULT_HARDWARE_DECODE,
|
||||||
vodQuality: DEFAULT_VOD_QUALITY,
|
vodQuality: DEFAULT_VOD_QUALITY,
|
||||||
liveQuality: DEFAULT_LIVE_QUALITY,
|
liveQuality: DEFAULT_LIVE_QUALITY,
|
||||||
|
hevcEnabled: DEFAULT_HEVC_ENABLED,
|
||||||
|
hevcProfile: DEFAULT_HEVC_PROFILE,
|
||||||
baseBitrate: new Map(DEFAULT_BITRATES)
|
baseBitrate: new Map(DEFAULT_BITRATES)
|
||||||
};
|
};
|
||||||
let latestStreamNum = 9999;
|
let latestStreamNum = 9999;
|
||||||
@ -42,6 +46,14 @@ async function register({ settingsManager, peertubeHelpers, transcodingManager:
|
|||||||
default: DEFAULT_HARDWARE_DECODE,
|
default: DEFAULT_HARDWARE_DECODE,
|
||||||
private: false
|
private: false
|
||||||
});
|
});
|
||||||
|
registerSetting({
|
||||||
|
name: 'hevc-encode',
|
||||||
|
label: 'Enable H265 NVENC',
|
||||||
|
type: 'input-checkbox',
|
||||||
|
descriptionHTML: 'Enables H265 NVENC (experimental)',
|
||||||
|
default: DEFAULT_HEVC_ENABLED,
|
||||||
|
private: false
|
||||||
|
});
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'vod-quality',
|
name: 'vod-quality',
|
||||||
label: 'VOD Quality',
|
label: 'VOD Quality',
|
||||||
@ -59,6 +71,19 @@ async function register({ settingsManager, peertubeHelpers, transcodingManager:
|
|||||||
default: DEFAULT_VOD_QUALITY.toString(),
|
default: DEFAULT_VOD_QUALITY.toString(),
|
||||||
private: false
|
private: false
|
||||||
});
|
});
|
||||||
|
registerSetting({
|
||||||
|
name: 'hevc-profile',
|
||||||
|
label: 'HEVC Profile',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
{ label: 'main', value: 'main' },
|
||||||
|
{ label: 'main10 (default)', value: 'main10' },
|
||||||
|
{ label: 'rext', value: 'rext' }
|
||||||
|
],
|
||||||
|
descriptionHTML: 'Set the HEVC profile',
|
||||||
|
default: DEFAULT_VOD_QUALITY.toString(),
|
||||||
|
private: false
|
||||||
|
});
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'live-quality',
|
name: 'live-quality',
|
||||||
label: 'Live Quality',
|
label: 'Live Quality',
|
||||||
@ -106,6 +131,8 @@ async function loadSettings(settingsManager) {
|
|||||||
pluginSettings.hardwareDecode = await settingsManager.getSetting('hardware-decode') == "true";
|
pluginSettings.hardwareDecode = await settingsManager.getSetting('hardware-decode') == "true";
|
||||||
pluginSettings.vodQuality = parseInt(await settingsManager.getSetting('vod-quality')) || DEFAULT_VOD_QUALITY;
|
pluginSettings.vodQuality = parseInt(await settingsManager.getSetting('vod-quality')) || DEFAULT_VOD_QUALITY;
|
||||||
pluginSettings.liveQuality = parseInt(await settingsManager.getSetting('live-quality')) || DEFAULT_LIVE_QUALITY;
|
pluginSettings.liveQuality = parseInt(await settingsManager.getSetting('live-quality')) || DEFAULT_LIVE_QUALITY;
|
||||||
|
pluginSettings.hevcProfile = parseInt(await settingsManager.getSetting('hevc-profile')) || DEFAULT_HEVC_PROFILE;
|
||||||
|
pluginSettings.hevcEnabled = parseInt(await settingsManager.getSetting('hevc-encode')) || DEFAULT_HEVC_ENABLED;
|
||||||
for (const [resolution, bitrate] of DEFAULT_BITRATES) {
|
for (const [resolution, bitrate] of DEFAULT_BITRATES) {
|
||||||
const key = `base-bitrate-${resolution}`;
|
const key = `base-bitrate-${resolution}`;
|
||||||
const storedValue = await settingsManager.getSetting(key);
|
const storedValue = await settingsManager.getSetting(key);
|
||||||
@ -115,6 +142,8 @@ async function loadSettings(settingsManager) {
|
|||||||
logger.info(`Hardware decode: ${pluginSettings.hardwareDecode}`);
|
logger.info(`Hardware decode: ${pluginSettings.hardwareDecode}`);
|
||||||
logger.info(`VOD Quality: ${pluginSettings.vodQuality}`);
|
logger.info(`VOD Quality: ${pluginSettings.vodQuality}`);
|
||||||
logger.info(`Live Quality: ${pluginSettings.liveQuality}`);
|
logger.info(`Live Quality: ${pluginSettings.liveQuality}`);
|
||||||
|
logger.info(`HEVC encode: ${pluginSettings.hevcEnabled}`);
|
||||||
|
logger.info(`HEVC profile: ${pluginSettings.hevcProfile}`);
|
||||||
}
|
}
|
||||||
function printResolution(resolution) {
|
function printResolution(resolution) {
|
||||||
switch (resolution) {
|
switch (resolution) {
|
||||||
@ -156,7 +185,30 @@ async function vodBuilder(params) {
|
|||||||
if (shouldInitVaapi && streamNum != undefined) {
|
if (shouldInitVaapi && streamNum != undefined) {
|
||||||
latestStreamNum = streamNum;
|
latestStreamNum = streamNum;
|
||||||
}
|
}
|
||||||
let options = {
|
let options = {};
|
||||||
|
if (pluginSettings.hevcEnabled) {
|
||||||
|
|
||||||
|
options = {
|
||||||
|
scaleFilter: {
|
||||||
|
name: 'scale'
|
||||||
|
},
|
||||||
|
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||||
|
outputOptions: [
|
||||||
|
`-preset ${pluginSettings.hevcQuality}`,
|
||||||
|
`-b:v${streamSuffix} ${targetBitrate}`,
|
||||||
|
//`-b:v${streamSuffix} 0`,
|
||||||
|
`-bufsize ${targetBitrate * 2}`,
|
||||||
|
`-profile:v${streamSuffix} ${pluginSettings.hevcProfile}`,
|
||||||
|
//`-cq 25`,
|
||||||
|
//`-rc vbr`,
|
||||||
|
`-c:v${streamSuffix} hevc_nvenc`,
|
||||||
|
//`-bf 4`
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
options = {
|
||||||
scaleFilter: {
|
scaleFilter: {
|
||||||
name: 'scale'
|
name: 'scale'
|
||||||
},
|
},
|
||||||
@ -173,6 +225,7 @@ async function vodBuilder(params) {
|
|||||||
`-bf 4`
|
`-bf 4`
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
}
|
||||||
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
@ -189,7 +242,32 @@ async function liveBuilder(params) {
|
|||||||
if (shouldInitVaapi && streamNum != undefined) {
|
if (shouldInitVaapi && streamNum != undefined) {
|
||||||
latestStreamNum = streamNum;
|
latestStreamNum = streamNum;
|
||||||
}
|
}
|
||||||
const options = {
|
|
||||||
|
let options = {};
|
||||||
|
|
||||||
|
if (pluginSettings.hevcEnabled) {
|
||||||
|
options = {
|
||||||
|
scaleFilter: {
|
||||||
|
name: 'scale'
|
||||||
|
},
|
||||||
|
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||||
|
outputOptions: [
|
||||||
|
`-tune ${pluginSettings.liveQuality}`,
|
||||||
|
`-r:v${streamSuffix} ${fps}`,
|
||||||
|
`-profile:v${streamSuffix} ${pluginSettings.hevcProfile}`,
|
||||||
|
`-c:v${streamSuffix} hevc_nvenc`,
|
||||||
|
//`-cq 25`,
|
||||||
|
`-g:v${streamSuffix} ${fps * 2}`,
|
||||||
|
`-b:v${streamSuffix} ${targetBitrate}`,
|
||||||
|
//`-b:v${streamSuffix} 0`,
|
||||||
|
`-bufsize ${targetBitrate * 2}`,
|
||||||
|
//`-rc vbr`,
|
||||||
|
// `-bf 4`
|
||||||
|
]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
|
||||||
|
options = {
|
||||||
scaleFilter: {
|
scaleFilter: {
|
||||||
name: 'scale'
|
name: 'scale'
|
||||||
},
|
},
|
||||||
@ -198,16 +276,16 @@ async function liveBuilder(params) {
|
|||||||
`-tune ${pluginSettings.liveQuality}`,
|
`-tune ${pluginSettings.liveQuality}`,
|
||||||
`-r:v${streamSuffix} ${fps}`,
|
`-r:v${streamSuffix} ${fps}`,
|
||||||
`-profile:v${streamSuffix} high`,
|
`-profile:v${streamSuffix} high`,
|
||||||
//`-c:v${streamSuffix} h264_nvenc`,
|
|
||||||
`-cq 25`,
|
`-cq 25`,
|
||||||
`-g:v${streamSuffix} ${fps * 2}`,
|
`-g:v${streamSuffix} ${fps * 2}`,
|
||||||
`-b:v${streamSuffix} ${targetBitrate}`,
|
`-b:v${streamSuffix} ${targetBitrate}`,
|
||||||
//`-b:v${streamSuffix} 0`,
|
|
||||||
`-bufsize ${targetBitrate * 2}`,
|
`-bufsize ${targetBitrate * 2}`,
|
||||||
//`-rc vbr`,
|
//`-rc vbr`,
|
||||||
`-bf 4`
|
`-bf 4`
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user