wheee
This commit is contained in:
parent
c50d491ed4
commit
aa9d12c3e9
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "peertube-plugin-nctv-nvenc-transcode",
|
"name": "peertube-plugin-nctv-nvenc-transcode",
|
||||||
"version": "1.0.0",
|
"version": "1.0.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "peertube-plugin-nctv-nvenc-transcode",
|
"name": "peertube-plugin-nctv-nvenc-transcode",
|
||||||
"version": "1.0.0",
|
"version": "1.0.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@peertube/peertube-types": "^5.1.0",
|
"@peertube/peertube-types": "^5.1.0",
|
||||||
|
@ -30,6 +30,6 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@peertube/peertube-types": "^5.1.0",
|
"@peertube/peertube-types": "^5.1.0",
|
||||||
"@tsconfig/node16": "^1.0.3",
|
"@tsconfig/node16": "^1.0.3",
|
||||||
"typescript": "^5.1.6"
|
"typescript": "^5.4.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
307
src/main.ts
307
src/main.ts
@ -1,50 +1,73 @@
|
|||||||
"use strict";
|
import { PluginSettingsManager, PluginTranscodingManager } from "@peertube/peertube-types"
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
import { EncoderOptions, EncoderOptionsBuilderParams, RegisterServerOptions, VideoResolution } from "@peertube/peertube-types"
|
||||||
exports.unregister = exports.register = void 0;
|
import { Logger } from 'winston'
|
||||||
let logger;
|
|
||||||
let transcodingManager;
|
let logger : Logger
|
||||||
const DEFAULT_HARDWARE_DECODE = false;
|
let transcodingManager : PluginTranscodingManager
|
||||||
const DEFAULT_VOD_QUALITY = "p4";
|
|
||||||
const DEFAULT_LIVE_QUALITY = "ull";
|
const DEFAULT_HARDWARE_DECODE : boolean = false
|
||||||
const DEFAULT_BITRATES = new Map([
|
const DEFAULT_VOD_QUALITY : string = 'p7'
|
||||||
[0, 64 * 1000],
|
const DEFAULT_LIVE_QUALITY : string = 'hq'
|
||||||
[144, 320 * 1000],
|
const DEFAULT_BITRATES : Map<VideoResolution, number> = new Map([
|
||||||
[360, 780 * 1000],
|
[VideoResolution.H_NOVIDEO, 64 * 1000],
|
||||||
[480, 1500 * 1000],
|
[VideoResolution.H_144P, 320 * 1000],
|
||||||
[720, 2800 * 1000],
|
[VideoResolution.H_360P, 780 * 1000],
|
||||||
[1080, 5200 * 1000],
|
[VideoResolution.H_480P, 1500 * 1000],
|
||||||
[1440, 10000 * 1000],
|
[VideoResolution.H_720P, 2800 * 1000],
|
||||||
[2160, 22000 * 1000]
|
[VideoResolution.H_1080P, 5200 * 1000],
|
||||||
]);
|
[VideoResolution.H_1440P, 10_000 * 1000],
|
||||||
let pluginSettings = {
|
[VideoResolution.H_4K, 22_000 * 1000]
|
||||||
|
])
|
||||||
|
|
||||||
|
interface PluginSettings {
|
||||||
|
hardwareDecode : boolean
|
||||||
|
vodQuality: string
|
||||||
|
liveQuality: string
|
||||||
|
baseBitrate: Map<VideoResolution, number>
|
||||||
|
}
|
||||||
|
let pluginSettings : 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,
|
||||||
baseBitrate: new Map(DEFAULT_BITRATES)
|
baseBitrate: new Map(DEFAULT_BITRATES)
|
||||||
};
|
}
|
||||||
let latestStreamNum = 9999;
|
|
||||||
async function register({ settingsManager, peertubeHelpers, transcodingManager: transcode, registerSetting }) {
|
let latestStreamNum = 9999
|
||||||
logger = peertubeHelpers.logger;
|
|
||||||
transcodingManager = transcode;
|
export async function register({settingsManager, peertubeHelpers, transcodingManager: transcode, registerSetting} :RegisterServerOptions) {
|
||||||
|
logger = peertubeHelpers.logger
|
||||||
|
transcodingManager = transcode
|
||||||
|
|
||||||
logger.info("Registering peertube-plugin-nctv-nvenc-transcode");
|
logger.info("Registering peertube-plugin-nctv-nvenc-transcode");
|
||||||
const encoder = 'h264_nvenc';
|
|
||||||
const profileName = 'nctv-nvenc';
|
const encoder = 'h264_nvenc'
|
||||||
transcodingManager.addVODProfile(encoder, profileName, vodBuilder);
|
const profileName = 'nctv-nvenc-v2'
|
||||||
transcodingManager.addVODEncoderPriority('video', encoder, 1000);
|
|
||||||
transcodingManager.addLiveProfile(encoder, profileName, liveBuilder);
|
// Add trasncoding profiles
|
||||||
transcodingManager.addLiveEncoderPriority('video', encoder, 1000);
|
transcodingManager.addVODProfile(encoder, profileName, vodBuilder)
|
||||||
await loadSettings(settingsManager);
|
transcodingManager.addVODEncoderPriority('video', encoder, 1000)
|
||||||
|
|
||||||
|
transcodingManager.addLiveProfile(encoder, profileName, liveBuilder)
|
||||||
|
transcodingManager.addLiveEncoderPriority('video', encoder, 1000)
|
||||||
|
|
||||||
|
// Load existing settings and default to constants if not present
|
||||||
|
await loadSettings(settingsManager)
|
||||||
|
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'hardware-decode',
|
name: 'hardware-decode',
|
||||||
label: 'Hardware decode',
|
label: 'Hardware Decode',
|
||||||
|
|
||||||
type: 'input-checkbox',
|
type: 'input-checkbox',
|
||||||
|
|
||||||
descriptionHTML: 'Use hardware video decoder instead of software decoder. This will slightly improve performance but may cause some issues with some videos. If you encounter issues, disable this option and restart failed jobs.',
|
descriptionHTML: 'Use hardware video decoder instead of software decoder. This will slightly improve performance but may cause some issues with some videos. If you encounter issues, disable this option and restart failed jobs.',
|
||||||
|
|
||||||
default: DEFAULT_HARDWARE_DECODE,
|
default: DEFAULT_HARDWARE_DECODE,
|
||||||
private: false
|
private: false
|
||||||
});
|
})
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'vod-quality',
|
name: 'vod-quality',
|
||||||
label: 'VOD Quality',
|
label: 'VOD Quality',
|
||||||
|
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'fastest', value: 'p1' },
|
{ label: 'fastest', value: 'p1' },
|
||||||
@ -55,108 +78,134 @@ async function register({ settingsManager, peertubeHelpers, transcodingManager:
|
|||||||
{ label: 'slower', value: 'p6' },
|
{ label: 'slower', value: 'p6' },
|
||||||
{ label: 'slowest', value: 'p7' }
|
{ label: 'slowest', value: 'p7' }
|
||||||
],
|
],
|
||||||
|
|
||||||
descriptionHTML: 'This parameter controls the speed / quality tradeoff. Slower speed mean better quality. Faster speed mean lower quality. This setting is hardware dependent, you may need to experiment to find the best value for your hardware.',
|
descriptionHTML: 'This parameter controls the speed / quality tradeoff. Slower speed mean better quality. Faster speed mean lower quality. This setting is hardware dependent, you may need to experiment to find the best value for your hardware.',
|
||||||
|
|
||||||
default: DEFAULT_VOD_QUALITY.toString(),
|
default: DEFAULT_VOD_QUALITY.toString(),
|
||||||
private: false
|
private: false
|
||||||
});
|
})
|
||||||
|
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'live-quality',
|
name: 'live-quality',
|
||||||
label: 'Live Quality',
|
label: 'Live Quality',
|
||||||
|
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: [
|
options: [
|
||||||
{ label: 'low latency (default)', value: 'll' },
|
{ label: 'low latency (default)', value: 'll' },
|
||||||
{ label: 'low latency high quality', value: 'hq' },
|
{ label: 'low latency high quality', value: 'hq' },
|
||||||
{ label: 'low latency high performance', value: 'ull' }
|
{ label: 'low latency high performance', value: 'ull' }
|
||||||
],
|
],
|
||||||
|
|
||||||
descriptionHTML: 'This parameter controls the speed / quality tradeoff. High performance mean lower quality.',
|
descriptionHTML: 'This parameter controls the speed / quality tradeoff. High performance mean lower quality.',
|
||||||
|
|
||||||
default: DEFAULT_LIVE_QUALITY.toString(),
|
default: DEFAULT_LIVE_QUALITY.toString(),
|
||||||
private: false
|
private: false
|
||||||
});
|
})
|
||||||
|
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'base-bitrate-description',
|
name: 'base-bitrate-description',
|
||||||
label: 'Base bitrate',
|
label: 'Base bitrate',
|
||||||
|
|
||||||
type: 'html',
|
type: 'html',
|
||||||
html: '',
|
html: '',
|
||||||
descriptionHTML: `The base bitrate for video in bits. We take the min bitrate between the bitrate setting and video bitrate.<br/>This is the bitrate used when the video is transcoded at 30 FPS. The bitrate will be scaled linearly between this value and the maximum bitrate when the video is transcoded at 60 FPS. Wrong values are replaced by default values.`,
|
descriptionHTML: `The base bitrate for video in bits. We take the min bitrate between the bitrate setting and video bitrate.<br/>This is the bitrate used when the video is transcoded at 30 FPS. The bitrate will be scaled linearly between this value and the maximum bitrate when the video is transcoded at 60 FPS. Wrong values are replaced by default values.`,
|
||||||
|
|
||||||
private: true,
|
private: true,
|
||||||
});
|
})
|
||||||
for (const [resolution, bitrate] of pluginSettings.baseBitrate) {
|
for (const [resolution, bitrate] of pluginSettings.baseBitrate) {
|
||||||
logger.info("registering bitrate setting: " + bitrate.toString());
|
logger.info("registering bitrate setting: "+ bitrate.toString())
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: `base-bitrate-${resolution}`,
|
name: `base-bitrate-${resolution}`,
|
||||||
label: `Base bitrate for ${printResolution(resolution)}`,
|
label: `Base bitrate for ${printResolution(resolution)}`,
|
||||||
|
|
||||||
type: 'input',
|
type: 'input',
|
||||||
|
|
||||||
default: DEFAULT_BITRATES.get(resolution)?.toString(),
|
default: DEFAULT_BITRATES.get(resolution)?.toString(),
|
||||||
descriptionHTML: `Default value: ${DEFAULT_BITRATES.get(resolution)}`,
|
descriptionHTML: `Default value: ${DEFAULT_BITRATES.get(resolution)}`,
|
||||||
|
|
||||||
private: false
|
private: false
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsManager.onSettingsChange(async (settings) => {
|
settingsManager.onSettingsChange(async (settings) => {
|
||||||
loadSettings(settingsManager);
|
loadSettings(settingsManager)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
exports.register = register;
|
|
||||||
async function unregister() {
|
export async function unregister() {
|
||||||
logger.info("Unregistering peertube-plugin-hardware-encode");
|
logger.info("Unregistering peertube-plugin-nctv-nvenc-transcode")
|
||||||
transcodingManager.removeAllProfilesAndEncoderPriorities();
|
transcodingManager.removeAllProfilesAndEncoderPriorities()
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
exports.unregister = unregister;
|
|
||||||
async function loadSettings(settingsManager) {
|
async function loadSettings(settingsManager: PluginSettingsManager) {
|
||||||
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') as string) || DEFAULT_VOD_QUALITY
|
||||||
pluginSettings.liveQuality = parseInt(await settingsManager.getSetting('live-quality')) || DEFAULT_LIVE_QUALITY;
|
pluginSettings.vodQuality = await settingsManager.getSetting('vod-quality') || DEFAULT_VOD_QUALITY
|
||||||
|
// pluginSettings.liveQuality = parseInt(await settingsManager.getSetting('live-quality') as string) || DEFAULT_LIVE_QUALITY
|
||||||
|
pluginSettings.liveQuality = await settingsManager.getSetting('live-quality') || DEFAULT_LIVE_QUALITY
|
||||||
|
|
||||||
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) as string
|
||||||
pluginSettings.baseBitrate.set(resolution, parseInt(storedValue) || bitrate);
|
pluginSettings.baseBitrate.set(resolution, parseInt(storedValue) || bitrate)
|
||||||
logger.info(`Bitrate ${printResolution(resolution)}: ${pluginSettings.baseBitrate.get(resolution)}`);
|
logger.info(`Bitrate ${printResolution(resolution)}: ${pluginSettings.baseBitrate.get(resolution)}`)
|
||||||
}
|
}
|
||||||
logger.info(`Hardware decode: ${pluginSettings.hardwareDecode}`);
|
|
||||||
logger.info(`VOD Quality: ${pluginSettings.vodQuality}`);
|
logger.info(`Hardware decode: ${pluginSettings.hardwareDecode}`)
|
||||||
logger.info(`Live Quality: ${pluginSettings.liveQuality}`);
|
logger.info(`VOD Quality: ${pluginSettings.vodQuality}`)
|
||||||
|
logger.info(`Live Quality: ${pluginSettings.liveQuality}`)
|
||||||
}
|
}
|
||||||
function printResolution(resolution) {
|
|
||||||
|
function printResolution(resolution : VideoResolution) : string {
|
||||||
switch (resolution) {
|
switch (resolution) {
|
||||||
case 0: return 'audio only';
|
case VideoResolution.H_NOVIDEO: return 'audio only'
|
||||||
case 144:
|
case VideoResolution.H_144P:
|
||||||
case 360:
|
case VideoResolution.H_360P:
|
||||||
case 480:
|
case VideoResolution.H_480P:
|
||||||
case 720:
|
case VideoResolution.H_720P:
|
||||||
case 1080:
|
case VideoResolution.H_1080P:
|
||||||
case 1440:
|
case VideoResolution.H_1440P:
|
||||||
return `${resolution}p`;
|
return `${resolution}p`
|
||||||
case 2160: return '4K';
|
case VideoResolution.H_4K: return '4K'
|
||||||
default: return 'Unknown';
|
|
||||||
|
default: return 'Unknown'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildInitOptions() {
|
function buildInitOptions() {
|
||||||
if (pluginSettings.hardwareDecode) {
|
if (pluginSettings.hardwareDecode) {
|
||||||
return [
|
return [
|
||||||
'-hwaccel cuda',
|
'-hwaccel cuda',
|
||||||
'-hwaccel_output_format cuda'
|
'-hwaccel_output_format cuda'
|
||||||
];
|
]
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return [
|
return [
|
||||||
'-hwaccel cuda'
|
'-hwaccel cuda'
|
||||||
];
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function vodBuilder(params) {
|
|
||||||
const { resolution, fps, streamNum, inputBitrate } = params;
|
async function vodBuilder(params: EncoderOptionsBuilderParams) : Promise<EncoderOptions> {
|
||||||
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`;
|
const { resolution, fps, streamNum, inputBitrate } = params
|
||||||
let targetBitrate = getTargetBitrate(resolution, fps);
|
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`
|
||||||
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum);
|
let targetBitrate = getTargetBitrate(resolution, fps)
|
||||||
|
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
|
||||||
}
|
}
|
||||||
let options = {
|
// You can also return a promise
|
||||||
|
let options : EncoderOptions = {
|
||||||
scaleFilter: {
|
scaleFilter: {
|
||||||
|
// software decode requires specifying pixel format for hardware filter and upload it to GPU
|
||||||
|
// name: pluginSettings.hardwareDecode ? 'scale_vaapi' : 'format=nv12,hwupload,scale_vaapi'
|
||||||
name: 'scale'
|
name: 'scale'
|
||||||
},
|
},
|
||||||
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||||
@ -165,45 +214,71 @@ async function vodBuilder(params) {
|
|||||||
`-b:v${streamSuffix} ${targetBitrate}`,
|
`-b:v${streamSuffix} ${targetBitrate}`,
|
||||||
`-bufsize ${targetBitrate * 2}`
|
`-bufsize ${targetBitrate * 2}`
|
||||||
]
|
]
|
||||||
};
|
}
|
||||||
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
logger.info(`EncoderOptions: ${JSON.stringify(options)}`)
|
||||||
return options;
|
return options
|
||||||
}
|
}
|
||||||
async function liveBuilder(params) {
|
|
||||||
const { resolution, fps, streamNum, inputBitrate } = params;
|
|
||||||
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`;
|
async function liveBuilder(params: EncoderOptionsBuilderParams) : Promise<EncoderOptions> {
|
||||||
let targetBitrate = getTargetBitrate(resolution, fps);
|
const { resolution, fps, streamNum, inputBitrate } = params
|
||||||
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum);
|
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`
|
||||||
|
let targetBitrate = getTargetBitrate(resolution, fps)
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// You can also return a promise
|
||||||
const options = {
|
const options = {
|
||||||
scaleFilter: {
|
scaleFilter: {
|
||||||
name: 'scale'
|
// name: pluginSettings.hardwareDecode ? 'scale_vaapi' : 'format=nv12,hwupload,scale_vaapi'
|
||||||
},
|
name: 'scale'
|
||||||
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
},
|
||||||
outputOptions: [
|
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||||
`-tune ${pluginSettings.liveQuality}`,
|
outputOptions: [
|
||||||
`-r:v${streamSuffix} ${fps}`,
|
`-tune ${pluginSettings.liveQuality}`,
|
||||||
`-profile:v${streamSuffix} main`,
|
`-r:v${streamSuffix} ${fps}`,
|
||||||
// `-level:v${streamSuffix} `,
|
`-profile:v${streamSuffix} high`,
|
||||||
`-g:v${streamSuffix} ${fps * 2}`,
|
// `-level:v${streamSuffix} 3.1`,
|
||||||
`-b:v${streamSuffix} ${targetBitrate}`,
|
`-g:v${streamSuffix} ${fps*2}`,
|
||||||
`-bufsize ${targetBitrate * 2}`
|
`-b:v${streamSuffix} ${targetBitrate}`,
|
||||||
]
|
`-bufsize ${targetBitrate * 2}`
|
||||||
};
|
]
|
||||||
logger.info(`EncoderOptions: ${JSON.stringify(options)}`);
|
}
|
||||||
return options;
|
logger.info(`EncoderOptions: ${JSON.stringify(options)}`)
|
||||||
|
return options
|
||||||
}
|
}
|
||||||
function getTargetBitrate(resolution, fps) {
|
|
||||||
const baseBitrate = pluginSettings.baseBitrate.get(resolution) || 0;
|
/**
|
||||||
const maxBitrate = baseBitrate * 1.4;
|
* Calculate the target bitrate based on video resolution and FPS.
|
||||||
const maxBitrateDifference = maxBitrate - baseBitrate;
|
*
|
||||||
const maxFpsDifference = 60 - 30;
|
* The calculation is based on two values:
|
||||||
return Math.floor(baseBitrate + (fps - 30) * (maxBitrateDifference / maxFpsDifference));
|
* Bitrate at VideoTranscodingFPS.AVERAGE is always the same as
|
||||||
}
|
* getBaseBitrate(). Bitrate at VideoTranscodingFPS.MAX is always
|
||||||
//# sourceMappingURL=main.js.map
|
* getBaseBitrate() * 1.4. All other values are calculated linearly
|
||||||
|
* between these two points.
|
||||||
|
*/
|
||||||
|
function getTargetBitrate (resolution : VideoResolution, fps : number) : number {
|
||||||
|
const baseBitrate = pluginSettings.baseBitrate.get(resolution) || 0
|
||||||
|
// The maximum bitrate, used when fps === VideoTranscodingFPS.MAX
|
||||||
|
// Based on numbers from Youtube, 60 fps bitrate divided by 30 fps bitrate:
|
||||||
|
// 720p: 2600 / 1750 = 1.49
|
||||||
|
// 1080p: 4400 / 3300 = 1.33
|
||||||
|
const maxBitrate = baseBitrate * 1.4
|
||||||
|
const maxBitrateDifference = maxBitrate - baseBitrate
|
||||||
|
const maxFpsDifference = 60 - 30
|
||||||
|
// For 1080p video with default settings, this results in the following formula:
|
||||||
|
// 3300 + (x - 30) * (1320/30)
|
||||||
|
// Example outputs:
|
||||||
|
// 1080p10: 2420 kbps, 1080p30: 3300 kbps, 1080p60: 4620 kbps
|
||||||
|
// 720p10: 1283 kbps, 720p30: 1750 kbps, 720p60: 2450 kbps
|
||||||
|
return Math.floor(baseBitrate + (fps - 30) * (maxBitrateDifference / maxFpsDifference))
|
||||||
|
}
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"extends": "@tsconfig/node16/tsconfig.json",
|
"extends": "@tsconfig/node16/tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"moduleResolution": "Node16", // Use Node.js 16-style module resolution
|
"module": "Node16", // Set this to 'Node16'
|
||||||
|
"moduleResolution": "Node16", // Set this to 'Node16'
|
||||||
"strict": true, // That implies alwaysStrict, noImplicitAny, noImplicitThis
|
"strict": true, // That implies alwaysStrict, noImplicitAny, noImplicitThis
|
||||||
|
|
||||||
"alwaysStrict": true, // should already be true because of strict:true
|
"alwaysStrict": true, // should already be true because of strict:true
|
||||||
|
@ -2874,10 +2874,10 @@ typedarray@^0.0.6:
|
|||||||
resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz"
|
resolved "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz"
|
||||||
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==
|
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==
|
||||||
|
|
||||||
typescript@^5.1.6:
|
typescript@^5.4.2:
|
||||||
version "5.1.6"
|
version "5.4.2"
|
||||||
resolved "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz"
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.2.tgz#0ae9cebcfae970718474fe0da2c090cad6577372"
|
||||||
integrity sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==
|
integrity sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==
|
||||||
|
|
||||||
uid-safe@2.1.5:
|
uid-safe@2.1.5:
|
||||||
version "2.1.5"
|
version "2.1.5"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user