DVR Recording Failed after Post Process Script QNAP

I wrote a post process script to convert my files from .ts to .mp4 on my QNAP TS-853A making use of the hardware transcoding ability of the celeron processor.

The script works great, apart from when the script is finished plex reports that the recording has failed, so it goes about finding a second, third or forth copy of the show to record. It also removes the history of the recording so it is difficult to work out from the schedule whether the show recorded or not. The recording has not failed, its just been transcoded to an mp4. How can I tell plex that the recording has been successful?

My script -

#!/bin/sh

#This part “refreshes” the NAS that it can do it! HW transcoding! I couldn’t fix this into the memory between reboots

export LD_LIBRARY_PATH=/share/CACHEDEV1_DATA/Multimedia/ffmpeg/lib:/share/CACHEDEV1_DATA/Multimedia/ffmpeg/lib/samba:$LD_LIBRARY_PATH
export LIBVA_DRIVER_NAME=i965
export LIBVA_DRIVERS_PATH=/share/CACHEDEV1_DATA/Multimedia/ffmpeg/lib/dri
export PATH=/share/CACHEDEV1_DATA/Multimedia/ffmpeg/bin:$PATH
/share/CACHEDEV1_DATA/Multimedia/ffmpeg/ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128

The actual FFMpeg options

-hwaccel_output_format vaapi -i “$1” -c:v h264_vaapi -c:a aac -b:a 256k -ac 2 “$1”.mp4

#Remove the original ts file. Plex was just moving the ts not the mp4 which didnt work for me

rm “$1”

I was having a similar issue when I was creating a post processing script. As far as I can tell, plex looks only for the .ts file. If it doesn’t find it, it will generate the error on the server. It will still move all the files in the temporary directory (there have been issues with this recently, see below link), but the error will be generated.

Possible solution

From looking at your script, it looks like your output file from ffmpeg will have .ts.mp4 as the extension. If that is true, you might try removing the .ts part from the output file.

Code for output file name

"${$1%.*}".mp4

This should strip any extension off the input file and then add the mp4 extension.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.