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 {
|
2021-04-03 23:35:16 +00:00
|
|
|
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: [
|
2021-04-03 23:35:16 +00:00
|
|
|
'-bf 8', // override hardcoded bf value which cause memory error
|
|
|
|
'-pix_fmt vaapi_vld'
|
2021-03-30 17:25:24 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-03 23:35:16 +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)
|
2021-04-03 23:35:16 +00:00
|
|
|
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
|
|
|
|
}
|