Compare commits
17 Commits
add-cq-con
...
2ef8b2deec
Author | SHA1 | Date | |
---|---|---|---|
2ef8b2deec | |||
6a150618b9 | |||
6640ba5c25 | |||
6a47bd9e77 | |||
bdcdb2e8e5 | |||
356caf37fd | |||
8483a37bae | |||
940ca6d751 | |||
9848e0de9f | |||
de17b72171 | |||
c92e017680 | |||
4b8b0e4888 | |||
b24c0e4ef7 | |||
ae2c910f20 | |||
ee56666c33 | |||
35ffb74383 | |||
84cc3a58cd |
48
dist/main.js
vendored
48
dist/main.js
vendored
@ -6,7 +6,6 @@ let transcodingManager;
|
||||
const DEFAULT_HARDWARE_DECODE = false;
|
||||
const DEFAULT_VOD_QUALITY = "p7";
|
||||
const DEFAULT_LIVE_QUALITY = "hq";
|
||||
const DEFAULT_CQ = 23;
|
||||
const DEFAULT_BITRATES = new Map([
|
||||
[0, 64 * 1000],
|
||||
[144, 320 * 1000],
|
||||
@ -21,7 +20,6 @@ let pluginSettings = {
|
||||
hardwareDecode: DEFAULT_HARDWARE_DECODE,
|
||||
vodQuality: DEFAULT_VOD_QUALITY,
|
||||
liveQuality: DEFAULT_LIVE_QUALITY,
|
||||
cqQuality: DEFAULT_CQ,
|
||||
baseBitrate: new Map(DEFAULT_BITRATES)
|
||||
};
|
||||
let latestStreamNum = 9999;
|
||||
@ -74,14 +72,6 @@ async function register({ settingsManager, peertubeHelpers, transcodingManager:
|
||||
default: DEFAULT_LIVE_QUALITY.toString(),
|
||||
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({
|
||||
name: 'base-bitrate-description',
|
||||
label: 'Base bitrate',
|
||||
@ -116,7 +106,6 @@ async function loadSettings(settingsManager) {
|
||||
pluginSettings.hardwareDecode = await settingsManager.getSetting('hardware-decode') == "true";
|
||||
pluginSettings.vodQuality = parseInt(await settingsManager.getSetting('vod-quality')) || DEFAULT_VOD_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) {
|
||||
const key = `base-bitrate-${resolution}`;
|
||||
const storedValue = await settingsManager.getSetting(key);
|
||||
@ -157,12 +146,12 @@ function buildInitOptions() {
|
||||
async function vodBuilder(params) {
|
||||
const { resolution, fps, streamNum, inputBitrate } = params;
|
||||
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`;
|
||||
// let targetBitrate = getTargetBitrate(resolution, fps);
|
||||
//let targetBitrate = getTargetBitrate(resolution, fps);
|
||||
let targetBitrate = inputBitrate;
|
||||
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum);
|
||||
// if (targetBitrate > inputBitrate) {
|
||||
// targetBitrate = inputBitrate;
|
||||
// }
|
||||
//if (targetBitrate > inputBitrate) {
|
||||
// targetBitrate = inputBitrate;
|
||||
//}
|
||||
logger.info(`Building encoder options, received ${JSON.stringify(params)}`);
|
||||
if (shouldInitVaapi && streamNum != undefined) {
|
||||
latestStreamNum = streamNum;
|
||||
@ -174,12 +163,14 @@ async function vodBuilder(params) {
|
||||
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||
outputOptions: [
|
||||
`-preset ${pluginSettings.vodQuality}`,
|
||||
// `-b:v${streamSuffix} ${targetBitrate}`,
|
||||
// `-bufsize ${targetBitrate * 2}`,
|
||||
//`-crf 21`, // increased 19 to 21, file size massive
|
||||
`-b:v${streamSuffix} ${targetBitrate}`,
|
||||
//`-b:v${streamSuffix} 0`,
|
||||
`-bufsize ${targetBitrate * 2}`,
|
||||
`-profile:v${streamSuffix} high`,
|
||||
`-cq 22`,
|
||||
`-c:v${streamSuffix} h264_nvenc`
|
||||
`-cq 21`,
|
||||
`-rc:v vbr`,
|
||||
`-c:v${streamSuffix} h264_nvenc`,
|
||||
`-bf 4`
|
||||
]
|
||||
};
|
||||
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
||||
@ -191,9 +182,9 @@ async function liveBuilder(params) {
|
||||
// let targetBitrate = getTargetBitrate(resolution, fps);
|
||||
let targetBitrate = inputBitrate;
|
||||
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum);
|
||||
// if (targetBitrate > inputBitrate) {
|
||||
//if (targetBitrate > inputBitrate) {
|
||||
// targetBitrate = inputBitrate;
|
||||
// }
|
||||
//}
|
||||
logger.info(`Building encoder options, received ${JSON.stringify(params)}`);
|
||||
if (shouldInitVaapi && streamNum != undefined) {
|
||||
latestStreamNum = streamNum;
|
||||
@ -205,13 +196,16 @@ async function liveBuilder(params) {
|
||||
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||
outputOptions: [
|
||||
`-tune ${pluginSettings.liveQuality}`,
|
||||
// `-r:v${streamSuffix} ${fps}`,
|
||||
`-r:v${streamSuffix} ${fps}`,
|
||||
`-profile:v${streamSuffix} high`,
|
||||
`-c:v${streamSuffix} h264_nvenc`,
|
||||
`-cq 22`
|
||||
// `-g:v${streamSuffix} ${fps * 2}`,
|
||||
// `-b:v${streamSuffix} ${targetBitrate}`,
|
||||
// `-bufsize ${targetBitrate * 2}`,
|
||||
`-cq 21`,
|
||||
`-g:v${streamSuffix} ${fps * 2}`,
|
||||
`-b:v${streamSuffix} ${targetBitrate}`,
|
||||
//`-b:v${streamSuffix} 0`,
|
||||
`-bufsize ${targetBitrate * 2}`,
|
||||
`-rc:v vbr`,
|
||||
`-bf 4`
|
||||
]
|
||||
};
|
||||
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "peertube-plugin-nctv-nvenc-transcode",
|
||||
"version": "1.0.7",
|
||||
"version": "1.1.1",
|
||||
"license": "MIT",
|
||||
"description": "Plugin that adds transcode profiles which use NVIDIA NVENC for hardware acceleration",
|
||||
"engine": {
|
||||
|
Reference in New Issue
Block a user