Compare commits
15 Commits
2a087cc3c0
...
add-cq-con
Author | SHA1 | Date | |
---|---|---|---|
901d20e265 | |||
98acf0be91 | |||
4c9ee97fb9 | |||
8fda9f4435 | |||
72d52d1580 | |||
1bd02a4902 | |||
21b28b35f2 | |||
92b9e78076 | |||
dff32f1466 | |||
1e7cc6961d | |||
70a974335f | |||
38936ff6ef | |||
506c47f3db | |||
e6e4097b5f | |||
39d08a8592 |
51
dist/main.js
vendored
51
dist/main.js
vendored
@ -6,6 +6,7 @@ let transcodingManager;
|
|||||||
const DEFAULT_HARDWARE_DECODE = false;
|
const DEFAULT_HARDWARE_DECODE = false;
|
||||||
const DEFAULT_VOD_QUALITY = "p7";
|
const DEFAULT_VOD_QUALITY = "p7";
|
||||||
const DEFAULT_LIVE_QUALITY = "hq";
|
const DEFAULT_LIVE_QUALITY = "hq";
|
||||||
|
const DEFAULT_CQ = 23;
|
||||||
const DEFAULT_BITRATES = new Map([
|
const DEFAULT_BITRATES = new Map([
|
||||||
[0, 64 * 1000],
|
[0, 64 * 1000],
|
||||||
[144, 320 * 1000],
|
[144, 320 * 1000],
|
||||||
@ -20,6 +21,7 @@ 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,
|
||||||
|
cqQuality: DEFAULT_CQ,
|
||||||
baseBitrate: new Map(DEFAULT_BITRATES)
|
baseBitrate: new Map(DEFAULT_BITRATES)
|
||||||
};
|
};
|
||||||
let latestStreamNum = 9999;
|
let latestStreamNum = 9999;
|
||||||
@ -72,6 +74,14 @@ async function register({ settingsManager, peertubeHelpers, transcodingManager:
|
|||||||
default: DEFAULT_LIVE_QUALITY.toString(),
|
default: DEFAULT_LIVE_QUALITY.toString(),
|
||||||
private: false
|
private: false
|
||||||
});
|
});
|
||||||
|
registerSetting({
|
||||||
|
name: 'constant-quality',
|
||||||
|
label: 'Constant Quality (-cq)',
|
||||||
|
descriptionHTML: 'Edit the constant quality (-cq) for videos. The lower the number, the higher the perceived visual fidelity and file size.',
|
||||||
|
type: 'input',
|
||||||
|
default: DEFAULT_CQ.toString(),
|
||||||
|
private: false,
|
||||||
|
});
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'base-bitrate-description',
|
name: 'base-bitrate-description',
|
||||||
label: 'Base bitrate',
|
label: 'Base bitrate',
|
||||||
@ -106,6 +116,7 @@ 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.cqQuality = parseInt(await settingsManager.getSetting('constant-quality')) || DEFAULT_CQ;
|
||||||
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);
|
||||||
@ -146,11 +157,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 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;
|
||||||
@ -162,10 +174,12 @@ async function vodBuilder(params) {
|
|||||||
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||||
outputOptions: [
|
outputOptions: [
|
||||||
`-preset ${pluginSettings.vodQuality}`,
|
`-preset ${pluginSettings.vodQuality}`,
|
||||||
// `-b:v${streamSuffix} ${targetBitrate}`,
|
// `-b:v${streamSuffix} ${targetBitrate}`,
|
||||||
// `-bufsize ${targetBitrate * 2}`,
|
// `-bufsize ${targetBitrate * 2}`,
|
||||||
// `-cq 21`, // increased 19 to 21, file size massive
|
//`-crf 21`, // increased 19 to 21, file size massive
|
||||||
`-profile:v${streamSuffix} high`
|
`-profile:v${streamSuffix} high`,
|
||||||
|
`-cq 22`,
|
||||||
|
`-c:v${streamSuffix} h264_nvenc`
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
||||||
@ -174,11 +188,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 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;
|
||||||
@ -190,13 +205,13 @@ async function liveBuilder(params) {
|
|||||||
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||||
outputOptions: [
|
outputOptions: [
|
||||||
`-tune ${pluginSettings.liveQuality}`,
|
`-tune ${pluginSettings.liveQuality}`,
|
||||||
`-r:v${streamSuffix} ${fps}`,
|
// `-r:v${streamSuffix} ${fps}`,
|
||||||
`-profile:v${streamSuffix} high`,
|
`-profile:v${streamSuffix} high`,
|
||||||
// `-level:v${streamSuffix} `,
|
`-c:v${streamSuffix} h264_nvenc`,
|
||||||
`-g:v${streamSuffix} ${fps * 2}`,
|
`-cq 22`
|
||||||
// `-b:v${streamSuffix} ${targetBitrate}`,
|
// `-g:v${streamSuffix} ${fps * 2}`,
|
||||||
// `-bufsize ${targetBitrate * 2}`,
|
// `-b:v${streamSuffix} ${targetBitrate}`,
|
||||||
// `-cq 19` // increase for accessibility
|
// `-bufsize ${targetBitrate * 2}`,
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "peertube-plugin-nctv-nvenc-transcode",
|
"name": "peertube-plugin-nctv-nvenc-transcode",
|
||||||
"version": "1.0.5",
|
"version": "1.0.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "Plugin that adds transcode profiles which use NVIDIA NVENC for hardware acceleration",
|
"description": "Plugin that adds transcode profiles which use NVIDIA NVENC for hardware acceleration",
|
||||||
"engine": {
|
"engine": {
|
||||||
|
Reference in New Issue
Block a user