Compare commits
2 Commits
e7ff13c14b
...
add-h264-p
Author | SHA1 | Date | |
---|---|---|---|
96ececa3f1 | |||
f81fa92956 |
41
dist/main.js
vendored
41
dist/main.js
vendored
@ -5,10 +5,11 @@ let logger;
|
||||
let transcodingManager;
|
||||
const DEFAULT_HARDWARE_DECODE = false;
|
||||
const DEFAULT_VOD_QUALITY = "p7";
|
||||
const DEFAULT_HEVC_PROFILE = "main10";
|
||||
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;
|
||||
@ -95,14 +97,27 @@ async function register({ settingsManager, peertubeHelpers, transcodingManager:
|
||||
label: 'HEVC Profile',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: 'main', value: 'main' },
|
||||
{ label: 'main10 (default)', value: 'main10' },
|
||||
{ label: 'main (default)', value: 'main' },
|
||||
{ label: 'main10', value: 'main10' },
|
||||
{ label: 'rext', value: 'rext' }
|
||||
],
|
||||
descriptionHTML: 'Set the HEVC profile',
|
||||
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',
|
||||
@ -148,11 +163,12 @@ async function unregister() {
|
||||
exports.unregister = unregister;
|
||||
async function loadSettings(settingsManager) {
|
||||
pluginSettings.hardwareDecode = await settingsManager.getSetting('hardware-decode') || DEFAULT_HARDWARE_DECODE;
|
||||
pluginSettings.vodQuality = parseInt(await settingsManager.getSetting('vod-quality')) || DEFAULT_VOD_QUALITY;
|
||||
pluginSettings.liveQuality = parseInt(await settingsManager.getSetting('live-quality')) || DEFAULT_LIVE_QUALITY;
|
||||
pluginSettings.hevcProfile = parseInt(await settingsManager.getSetting('hevc-profile')) || DEFAULT_HEVC_PROFILE;
|
||||
pluginSettings.vodQuality = await settingsManager.getSetting('vod-quality') || DEFAULT_VOD_QUALITY;
|
||||
pluginSettings.liveQuality = await settingsManager.getSetting('live-quality') || DEFAULT_LIVE_QUALITY;
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user