Synology Post Processing Script

Server Version#: 1.23.4.4805 and about to update

I use a HDHomeRun Connect to record live TV and have been struggling for a while getting a Post Processing script to run successfully, I am using FFMPEG and I believe I have it installed correctly (but I’m not 100% sure) but I consistently get “An error occurred while postprocessing the recording”
Under DSM7.0 I have the script in /volume1/@apphome/PlexMediaServer/‘Plex Media Server’/Scripts and I again believe all the permissions are set correctly.
I have no idea on how to troubleshoot this, can someone ‘give’ me a Synology script that will just do something simple like putting a customised message into a log file so I can prove that at least the script is being found and run?

Thanks

This is the script I use. It save’s a log in /volume1/Media

#!/bin/bash

this is a shell script to call ffmpeg to transcode Plex videos to h264

dvrPostLog=‘/volume1/Media/DVRPostProcessing.log’

echo “=================================” | tee -a $dvrPostLog

[ $# -ge 1 -a -f “$1” ]

infile=$1

outfile=“${1%.ts}TMP.ts”

echo “date '+%Y-%m-%d'” | tee -a $dvrPostLog

echo “date '+%H:%M:%S' file ‘$1’ is opened, trying to use hardware accel.” | tee -a $dvrPostLog

echo “date '+%H:%M:%S' writing transcode to temp file: ‘$outfile’” | tee -a $dvrPostLog

#make sure you use the version of FFmpeg that is installed with the package. DSM ships with an older version that is default. Here is how to call the newer build explicitly, with hardware encoding flags:
#This version directs the errors to a log file for debugging.
/var/packages/ffmpeg/target/bin/ffmpeg -init_hw_device vaapi=foo:/dev/dri/renderD128 -hwaccel vaapi -hwaccel_device foo -hwaccel_output_format vaapi -i “$infile” -filter_hw_device foo -acodec copy -vcodec h264_vaapi -preset veryfast -loglevel info “$outfile” > /dev/null

finished with ffmpeg encode

echo “date '+%H:%M:%S' ffmpeg has finished encoding. Renamed old file to .ts” | tee -a $dvrPostLog

remove the old file; rename the converted file to .ts bc Plex wants this.

rm -f “$infile”
mv -f “$outfile” “$infile”

echo “date '+%H:%M:%S' conversion done. old file deleted. new file saved in .ts” | tee -a $dvrPostLog

M.

Food for thought - but all I want at this stage is a simplified script that does no processing apart from putting a message in a log file, once I know the (correct) script is being executed (correctly) then I can start to build some functionality into it

Create your post processing scipt call it test.sh and stick it in

/volume1/@apphome/PlexMediaServer/‘Plex Media Server’/Scripts

Just use these two lines to create a log and the contents of the log will be “testing Log Creation”

dvrPostLog=’/volume1/Media/DVRPostProcessing.log’
echo “testing Log creation” | tee -a $dvrPostLog

If the file gets created you know it’s working, just change the path to where you want the log to be created. mine gets created in the Media share.

M.

Thank You

Within Plex do you put

/volume1/@apphome/PlexMediaServer/‘Plex Media Server’/Scripts/DVRPostProcessing.sh

or just

DVRPostProcessing.sh

Any ideas what error or exit code 13 means?

Jul 22, 2021 14:04:58.013 [0x7f75cdc22b38] DEBUG - [Grabber/08e66cf25e04557e7d79173ddc5c0aa62bfc029a/JobRunner] Job running: ‘/volume1/@apphome/PlexMediaServer/Plex Media Server/Scripts/DVRPostProcessing.sh’ ‘/volume1/Secondary/Media/Media/TV/DVR TV/.grab/08e66cf25e04557e7d79173ddc5c0aa62bfc029a-7608c1f0c61c8ad31df23f15c8669cda7d221372/Law & Order (1990) - S10E13 - Panic.ts’
Jul 22, 2021 14:04:58.013 [0x7f75cdc22b38] DEBUG - [Grabber/08e66cf25e04557e7d79173ddc5c0aa62bfc029a/JobRunner] Jobs: Starting child process with pid 20151
Jul 22, 2021 14:04:58.013 [0x7f75d3014b38] DEBUG - Jobs: ‘/volume1/@apphome/PlexMediaServer/Plex Media Server/Scripts/DVRPostProcessing.sh’ exit code for process 20151 is 13 (failure)
Jul 22, 2021 14:04:58.013 [0x7f75cdc22b38] ERROR - [Grabber/08e66cf25e04557e7d79173ddc5c0aa62bfc029a] Recorder: Postprocessing script ‘/volume1/@apphome/PlexMediaServer/Plex Media Server/Scripts/DVRPostProcessing.sh’ exited with error code 13.

I have added the ‘server-synology’ tag back in to indicate it is a Linux script.

I’m afraid I don’t know… usually I test the DVR scripts by SSH’ing into the Synology elevating myself to root, and running the scripts from there. Once I’m sure it’s working the last step is to put it into the GUI and test a recording.

error 13 could be permission denied but to sure…

M.

Thanks again

I have SSH’d in and run the script and while it did run there was a logfile called ‘dvrProcessing.log’$’\r\r’ created which contained the line ‘testing Log creation’

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