diff --git a/README.md b/README.md index ac61b0e..a259eb8 100644 --- a/README.md +++ b/README.md @@ -338,6 +338,7 @@ The image extends the [LinuxServer Plex](https://hub.docker.com/r/linuxserver/pl | Parameter | Function | | :----: | --- | +| `FFMPEG_HWACCEL` | Allows a [hwaccel decoder](https://trac.ffmpeg.org/wiki/HWAccelIntro) to be passed to ffmpeg such as `nvdec` or `dvxa2` | | `LISTENING_PORT` | Port where workers expose the internal healthcheck | | `STAT_CPU_INTERVAL` | Frequency at which the worker sends stats to the orchestrator (in ms). Default 2000 | | `ORCHESTRATOR_URL` | The url where the orchestrator service can be reached (ex: http://plex-orchestrator:3500) | diff --git a/worker/app/worker.js b/worker/app/worker.js index dfab424..6618117 100644 --- a/worker/app/worker.js +++ b/worker/app/worker.js @@ -4,6 +4,8 @@ const STAT_CPU_OPS_DURATION = process.env.STAT_CPU_OPS_DURATION || 1000 const ORCHESTRATOR_URL = process.env.ORCHESTRATOR_URL || 'http://localhost:3500' const TRANSCODER_PATH = process.env.TRANSCODER_PATH || '/usr/lib/plexmediaserver/' const TRANSCODER_NAME = process.env.TRANSCODER_NAME || 'Plex Transcoder' +// hwaccel decoder: https://trac.ffmpeg.org/wiki/HWAccelIntro +const FFMPEG_HWACCEL = process.env.FFMPEG_HWACCEL || false var app = require('express')(); var server = require('http').createServer(app); @@ -83,6 +85,16 @@ socket.on('worker.task.request', taskRequest => { console.log('Starting test of waiting for 5 seconds') child = exec('sleep 5'); } else { + if (FFMPEG_HWACCEL != false) { + console.log(`Setting hwaccel to ${FFMPEG_HWACCEL}`) + let i = taskRequest.payload.args.indexOf('-hwaccel') + if (i > 0) { + taskRequest.payload.args[i+1] = FFMPEG_HWACCEL + } else { + taskRequest.payload.args.unshift('-hwaccel', FFMPEG_HWACCEL) + } + } + child = spawn(TRANSCODER_PATH + TRANSCODER_NAME, taskRequest.payload.args, { cwd: taskRequest.payload.cwd, env: processedEnvironmentVariables