Is it possible to control the library paths for HandBrakeCLI in a Plex post-processing script?

I am trying to run a fairly basic post-processing script that would transcode a DVR recording using HandbrakeCLI (I am using the nightlies repository on Ubuntu 17.10 64). I am getting the following error messages:

Jan 9 11:30:01 [user] sh[950]: HandBrakeCLI: /usr/lib/plexmediaserver/libxml2.so.2: no version information available (required by HandBrakeCLI)
Jan 9 11:30:01 [user] sh[950]: HandBrakeCLI: /usr/lib/plexmediaserver/libxml2.so.2: no version information available (required by HandBrakeCLI)
Jan 9 11:30:01 [user] sh[950]: HandBrakeCLI: /usr/lib/plexmediaserver/libz.so.1: version `ZLIB_1.2.9’ not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16)

There are two versions of each of these files, one in the usual standalone location and one in /usr/lib/plexmediaserver. I don’t want to remove the plex version and link to the other (one solution proposed for this kind of error generally), since I am afraid I will break Plex if I do so. I would like to be able to force HandBrakeCLI to use the default versions of these libraries, but have not yet found anything online addressing this. Has anyone encountered a similar path issue in post-processing, and if so how did you fix it?

I seem to have answered my own question with a bit more googling and trial and error - the solution to the HandBrakeCLI errors was to add a line before the HandBrakeCLI command that changed the library path environment variable to remove /usr/lib/plexmediaserver; after the Handbrake command completes, the script then restores the prior library path variable (not sure that was necessary, but just in case):

#!/bin/bash
startfile="$1"
echo $startfile >> /home/[user]/UFTest.log
midfile=$(basename “$startfile”)
echo $midfile >> /home/[user]/UFTest.log
newfile=$(sed -e ‘s/’.ts’/’.uf.mp4’/g’ <<< $midfile)
echo $newfile >> /home/[user]/UFTest.log
outpath="/home/[user]/[subdir]/[subdir]/Plex/FastSaves/"
output=$outpath$newfile
echo $output >> /home/[user]/UFTest.log
stamp=$(date)
echo $stamp >> /home/[user]/UFTest.log
echo $LD_LIBRARY_PATH >> /home/[user]/UFTest.log
echo $PATH >> /home/[user]/UFTest.log
fullenv=$(printenv)
echo $fullenv >> /home/[user]/UFTest.log
oldldpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH="/lib/x86_64-linux-gnu"
echo $LD_LIBRARY_PATH >> /home/[user]/UFTest.log
HandBrakeCLI --preset-import-file /home/[user]/Ultrafast720p30.json -v -Z "Ult$
export LD_LIBRARY_PATH=$oldldpath
echo $stamp >> /home/[user]/UFTest.log

1 Like

Thank you for posting your resolution. It helped me fix my own post-processing woes. In my case it was with ffmpeg.

ffmpeg: /usr/lib/plexmediaserver/libz.so.1: version `ZLIB_1.2.9' not found (required by /usr/lib/x86_64-linux-gnu/libpng16.so.16)

Added this to my script and it resolved the problem.

export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu"