Synology DS418Play post processing script

I have a Synology DS418Play and for a few hours I have been copying and pasting a post processing script together and I figured I would share it and archive it.

Here is what I have installed
Plex Server Version#: 1.21.3.4015
ffmpeg 4.3.1-35 - from SynoCommunity
HDHomeRun Connect Quatro

Place the script in:

/volume1/Plex/Library/Application Support/Plex Media Server/Scripts/plexpostprocess.sh

Here is what the script does:

  • Take the TS recording from the HD tuner
  • Boost the audio
  • Use hardware acceleration with vaapi
  • Deinterlace the video
  • Set the quality to 24 (read it was the best for h.265)
  • Make sure the frame rate is correct
  • Save it to an hevc mp4 flle
  • Delete the TS file
  • Out put a log of what is going on

If you decide to use the script don’t forget to set the owner to the plex user and save it with an .sh extension.

#!/bin/bash
dvrPostLog='/volume1/Plex/dvrProcessing.log'
echo "=================================" | tee -a $dvrPostLog
[ $# -ge 1 -a -f "$1" ]
echo "`date '+%Y-%m-%d'`" | tee -a $dvrPostLog
echo "`date '+%H:%M:%S'` file '$1' is opened" | tee -a $dvrPostLog

echo "Detecting Audio Level..."  | tee -a $dvrPostLog
amplify=$(/usr/local/ffmpeg/bin/ffmpeg -i "$1" -af "volumedetect" -vn -sn -dn -f null - 2>&1 | awk '/max_volume/ { print $NF } /dB/' | tail -c 8 | sed 's/...$//' | sed 's/^.//')
echo "Amplify By ${amplify} dB"  | tee -a $dvrPostLog
af="-af volume=${amplify}dB,aresample="matrix_encoding=dplii""

/usr/local/ffmpeg/bin/ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i "$1" -vf "deinterlace_vaapi=rate=field:auto=1" -c:v hevc_vaapi -global_quality 24 -r 30000/1001 ${af} "${1%.ts}.mp4"

echo "`date '+%H:%M:%S'` conversion done. new file saved" | tee -a $dvrPostLog
rm "$1"
echo "`date '+%H:%M:%S'` file '$1'.ts deleted" | tee -a $dvrPostLog

plexpostprocess.txt (992 Bytes)

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