Transcode to H.264 MP4 container after recording.

I have the comskip on which works for most everything I record. I usually let a full week of recordings build up and then run Handbrake on them to convert them to MP4 and move them from my RecordedTV drive to my NAS for long term storage. I would like to figure out what I could run after the file is comskipped to automate this process. Maybe after the recording is done and comskip is run Plex could start up ffmpeg (I am not sure at all how to set this up) convert the file to the desired settings and move the file the correct directory… I run in Linux Mint so MCEBuddy is not an option! If there is anyone willing to help I would appreciate it!

Create shell scripts that run via crontab to execute ffmpeg with the desired switches and move the files.

I have a cronjob that runs at 2 am everday, grabs everything in the plex dvr library, runs it through ffmpeg, and then moves everything to network storage. I gave up trying to get plex to reliably run scripts after recording.

#!/bin/bash

temp_dir="/usr/lib/plex"
transcode_dir="$temp_dir/transcode"

if [ ! -d $temp_dir ]; then
    mkdir $temp_dir
    mkdir $transcode_dir
fi

log_file="$temp_dir/test-custom_transcode.log"

mv /plex-tv/* $transcode_dir

find $transcode_dir -type f -name '*.ts' -not -path '\/.*' > $temp_dir/files-to-transcode

while IFS= read input_file; do

    echo "custom-transcode.sh $input_file" >> $log_file

    file_name=$(echo $input_file | awk 'BEGIN{FS="/";} { print $NF; }')
    echo "file_name: $file_name" >> $log_file

    temp_file="$temp_dir/$file_name"
    echo "temp_file: $temp_file" >> $log_file

    echo "" >> $log_file

    /usr/bin/ffmpeg -nostdin -i "$input_file" -c:a copy -c:v libx264 -preset medium -profile:v high -level 4.0 -deinterlace "$temp_file" &
    wait $!

    mv -v "$temp_file" "$input_file"

done < $temp_dir/files-to-transcode

cd $transcode_dir

if [ -d /mnt/raid/tv ]; then

    cp -r ./* /mnt/raid/tv

    rm -r ./*

fi

It’s not a very robust script. For example, the cronjob has to call it as root, and the parameters to ffmpeg only outputs the primary audio stream.

I will look into setting something like that up. I did my thing this week on Saturday morning and I had 55 recordings to do and it took all damn day! I’d like to get to where I am really doing nothing and it just works. Primary audio is fine and I do not want subtitles so what you show me here should work. I just have to learn how to implement it…

I have found the plex postprocessing script option to be extremely reliable. Frankly, I’d say its been one of the few reliable things about Plex DVR. This is on Centos; not sure if other flavors are less reliable.