peertube-plugin-nctv-nvenc-.../main.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-03-30 17:25:24 +00:00
async function register ({
transcodingManager
}) {
// Adapt bitrate when using libx264 encoder
{
const builder = (options) => {
const { input, resolution, fps, streamNum } = options
// You can also return a promise
return {
videoFilters: [
'hwupload'
],
inputOptions: [
// enable hardware acceleration
'-hwaccel vaapi',
'-hwaccel_output_format vaapi',
'-vaapi_device /dev/dri/renderD128'
],
2021-03-30 17:25:24 +00:00
outputOptions: [
'-bf 8', // override hardcoded bf value which cause memory error
'-pix_fmt vaapi_vld'
2021-03-30 17:25:24 +00:00
]
}
}
const encoder = 'h264_vaapi'
const profileName = 'vaapi'
2021-03-30 17:25:24 +00:00
// Support this profile for VOD transcoding
transcodingManager.addVODProfile(encoder, profileName, builder)
transcodingManager.addVODEncoderPriority('video', encoder, 1000)
2021-03-30 17:25:24 +00:00
// And/Or support this profile for live transcoding
transcodingManager.addLiveProfile(encoder, profileName, builder)
}
}
async function unregister() {
return true;
}
module.exports = {
register,
unregister
}