#!/bin/sh VIDEODIR=$1 FILENAME=$2 #sam# mod from discussion page needed for honorcutlist CHANID=$3 STARTTIME=`echo $4 | sed -e 's/\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1\2\3\4\5/'` #sam# grab the title for the output file name TITLE=$5 SUBTITLE=$6 # Sanity checking, to make sure everything is in order. if [ -z "$VIDEODIR" -o -z "$FILENAME" ]; then echo "Usage: $0 " exit 5 fi if [ ! -f "$VIDEODIR/$FILENAME" ]; then echo "File does not exist: $VIDEODIR/$FILENAME" exit 6 fi # The meat of the script. Flag commercials, copy the flagged commercials to # the cutlist, and transcode the video to remove the commercials from the # file. #sam# Here I assume commercials have been flagged and cutlist generated ##### already via Edit mode and 'z' on the frontend #mythcommflag -f $VIDEODIR/$FILENAME #ERROR=$? #if [ $ERROR -gt 126 ]; then # echo "Commercial flagging failed for ${FILENAME} with error $ERROR" # exit $ERROR #fi #mythcommflag --gencutlist -f $VIDEODIR/$FILENAME #ERROR=$? #if [ $ERROR -ne 0 ]; then # echo "Copying cutlist failed for ${FILENAME} with error $ERROR" # exit $ERROR #fi #sam# now include title in filename mythtranscode --mpeg2 --honorcutlist -c $CHANID -s $STARTTIME -o /var/lib/mythtv/videos/Kids/$TITLE$SUBTITLE.mpg ERROR=$? if [ $ERROR -ne 0 ]; then echo "Transcoding failed for ${FILENAME} with error $ERROR" exit $ERROR fi #sam# don't need any of this #sam# I will delete the recording from the frontend if this #sam# script works #mv $VIDEODIR/$FILENAME $VIDEODIR/$FILENAME.old #mv $VIDEODIR/$FILENAME.tmp $VIDEODIR/$FILENAME #mythcommflag -f $VIDEODIR/${FILENAME} --rebuild #ERROR=$? #if [ $ERROR -ne 0 ]; then # echo "Rebuilding seek list failed for ${FILENAME} with error $ERROR" # exit $ERROR #fi #mythcommflag --clearcutlist -f $VIDEODIR/$FILENAME #ERROR=$? #if [ $ERROR -eq 0 ]; then # # Fix the database entry for the file # cat << EOF | mysql mythconverg #UPDATE # recorded #SET # cutlist = 0, # filesize = $(ls -l $VIDEODIR/$FILENAME | awk '{print $5}') #WHERE # basename = '$FILENAME'; #EOF exit 0 #else # echo "Clearing cutlist failed for ${FILENAME} with error $ERROR" # rm /usr/video/$FILENAME.tmp # exit $ERROR #fi