Project

General

Profile

Post Processing Scripts

Added by Bob Lightfoot almost 10 years ago

The wiki mentions post recording scripts here and I thought I'd share my mods to those for others:
https://tvheadend.org/projects/tvheadend/wiki/Tvheadend_post_recording_scripts

This script can be called from the DVR Post Processing command as "/usr/share/tvheadend/scripts/postprocessing.sh %f %b %e 'command'" where command is comskip or compact. It assumes recordings are in /video/Recordings/SeriesName and compact videos go to /video/videos.

[quote]

#!/bin/sh

  1. variables
    TSVIDEO=$1 #Full path to recording /video/Recordings/%{ShowName}/%{FileName.ext}
    basename=$2 #Basename of recording FileName.ext
    error=$3 #error from tvheadend recorder "OK" if no error
    command=$4 #Type of Post Processing to do comskip or compact
    compactbase=$(echo "$basename" | sed "s/...$//") # Remove file ext (3 char)
  1. exit if not ok
    if [ $error != "OK" ]; then
    echo " Not OK"
    exit 1
    fi
  1. Determine Length of Pathname & Filename
    TS=${#TSVIDEO}
  2. echo $TS
  1. Determine Length of the Filename Only
    base=${#basename}
  2. echo $base
  1. Calcualte the difference between filename and full path length
    let TSPATHlen=$TS-$base
  2. echo $TSPATHlen
  1. Strip Filename down to Filepath
    TSPATH="${TSVIDEO:0:$TSPATHlen}"
  1. Debug Outputs for testing script works
  2. echo " Original Full File Name "
  3. echo $TSVIDEO
  1. echo " Stripped Down Path "
  2. echo $TSPATH
  1. Check if command is comskip and then issue comskip command
    if [ $command = "comskip" ]; then
    /usr/bin/comskip -t -d 13 $TSVIDEO $TSPATH
    exit 0
    fi
  1. Check if command is compact and then issue proper ffmpeg command
    if [ $command = "compact" ]; then
    COMPACTVIDEO="/video/videos/$compactbase.mp4"
    /usr/bin/ffmpeg -i $TSVIDEO -vcodec h264 -acodec mp3 -crf 30 $COMPACTVIDEO
    exit 0
    fi

if [ $command = "" ]; then
/usr/bin/comskip -t -d 13 $TSVIDEO $TSPATH
exit 0
fi

[/quote]


Replies (1)

RE: Post Processing Scripts - Added by Bob Lightfoot almost 10 years ago

The following script called from crontab also cleans up when tvheadend deletes the comskip files when xbmc or tvheadend removes the ts file.

    (1-1/1)