Tony_T
February 7, 2025, 11:34pm
1
Trying to get a Postprocessing script to do HW encoding.
This works when tested, but not when placed in the Plex Scripts directory:
#!/bin/bash
inFile="$1"
outFile="${inFile%.*}.mkv"
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i "$inFile" -map 0 -c:v h264_vaapi -c:a copy "$outFile"
Found the error, just need to find out why this error only occurs when in the Plex Script directory:
[AVHWDeviceContext @ 0x60fa83689a00] Failed to initialise VAAPI connection: -1 (unknown libva error).
Device creation failed: -5.
No device available for decoder: device type vaapi needed for codec mpeg2video.
Tony_T
February 8, 2025, 3:45pm
3
Found the solution (with ChatGPT)
Needed to add:
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
Full Post Processing Script with hw encoding :
#!/bin/bash
# Plex DVR Post Processing
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
inFile="$1"
outFile="${inFile%.*}.mkv"
# Hardware encode:
ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i "$inFile" -map 0 -c:v h264_vaapi -c:a copy "$outFile"
rm "$inFile"
Also got quicksyc working with sudo apt install libmfx-gen1.2, but I’m getting better results with vaapi, so I’m sticking with that.