only apply vaapi init parameter when needed
This commit is contained in:
parent
777803c6c9
commit
70b62037d6
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Hardware h264 encoding using vaapi
|
||||
|
||||
TODO
|
||||
|
||||
See these to setup vaapi:
|
||||
|
||||
- https://jellyfin.org/docs/general/administration/hardware-acceleration.html#enabling-hardware-acceleration
|
||||
- https://wiki.archlinux.org/index.php/Hardware_video_acceleration#Comparison_tables
|
32
main.js
32
main.js
@ -4,23 +4,30 @@ async function register ({
|
||||
}) {
|
||||
|
||||
const { logger } = peertubeHelpers
|
||||
const initVaapiOptions = [
|
||||
// enable hardware acceleration
|
||||
'-hwaccel vaapi',
|
||||
'-hwaccel_output_format vaapi',
|
||||
'-vaapi_device /dev/dri/renderD128'
|
||||
]
|
||||
let latestStreamNum = 9999
|
||||
|
||||
// Add hardware encode through vaapi
|
||||
{
|
||||
const VODBuilder = (options) => {
|
||||
const { input, resolution, fps, streamNum } = options
|
||||
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`
|
||||
const targetBitrate = getTargetBitrate(resolution, fps)
|
||||
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum)
|
||||
|
||||
if (shouldInitVaapi && streamNum != undefined) {
|
||||
latestStreamNum = streamNum
|
||||
}
|
||||
// You can also return a promise
|
||||
return {
|
||||
videoFilters: [
|
||||
],
|
||||
inputOptions: [
|
||||
// enable hardware acceleration
|
||||
'-hwaccel vaapi',
|
||||
'-hwaccel_output_format vaapi',
|
||||
'-vaapi_device /dev/dri/renderD128'
|
||||
],
|
||||
inputOptions: shouldInitVaapi ? initVaapiOptions : [],
|
||||
outputOptions: [
|
||||
'-bf 8', // override hardcoded bf value which cause memory error
|
||||
'-pix_fmt vaapi_vld',
|
||||
@ -36,17 +43,17 @@ async function register ({
|
||||
const { input, resolution, fps, streamNum } = options
|
||||
const streamSuffix = streamNum == undefined ? '' : `:${streamNum}`
|
||||
const targetBitrate = getTargetBitrate(resolution, fps)
|
||||
let shouldInitVaapi = (streamNum == undefined || streamNum <= latestStreamNum)
|
||||
|
||||
if (shouldInitVaapi && streamNum != undefined) {
|
||||
latestStreamNum = streamNum
|
||||
}
|
||||
|
||||
// You can also return a promise
|
||||
return {
|
||||
videoFilters: [
|
||||
],
|
||||
inputOptions: [
|
||||
// enable hardware acceleration
|
||||
'-hwaccel vaapi',
|
||||
'-hwaccel_output_format vaapi',
|
||||
'-vaapi_device /dev/dri/renderD128'
|
||||
],
|
||||
inputOptions: shouldInitVaapi ? initVaapiOptions : [],
|
||||
outputOptions: [
|
||||
'-bf 8', // override hardcoded bf value which cause memory error
|
||||
'-pix_fmt vaapi_vld',
|
||||
@ -76,6 +83,7 @@ async function register ({
|
||||
}
|
||||
|
||||
async function unregister() {
|
||||
transcodingManager.removeAllProfilesAndEncoderPriorities()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "peertube-plugin-hardware-transcode-vaapi",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.3",
|
||||
"description": "Plugin add transcode profils which use vaapi for hardware acceleration",
|
||||
"engine": {
|
||||
"peertube": ">=3.1.0"
|
||||
|
Loading…
Reference in New Issue
Block a user