[mythtv-users] Odd mythtranscode --mpeg2 behavior

N.R mythtv at nrudd.com
Tue Apr 10 15:22:47 UTC 2007


I am attempting to use the script below to automatically remove 
commercials from new recordings, using the mythtranscode lossless 
transcoding ability.  It completes successfully, and the videos it 
produces are viewable in mythtv, but not on a windows machine.  I can 
usually copy the .mpg to a windows machine and play it, but it can't 
tell what codec the transcoded videos use.

Also, these are 30 minute shows, transcoded to remove commercials 
(approximately 7.5min per 30), so I would expect the file size to be 
approximately 75% of the original.  The output files I am getting are 
around 20% of the original.  Any ideas?

removeCommercials script:

#!/bin/sh
VIDEODIR=$1
FILENAME=$2
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/'`

# Sanity checking, to make sure everything is in order.
if [ -z "$VIDEODIR" -o -z "$FILENAME" ]; then
        echo "Usage: $0 <VideoDirectory> <FileName>"
        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.
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
mythtranscode --mpgeg2 --honorcutlist -c $CHANID -s $STARTTIME -o $VIDEODIR/$FILENAME.tmp
ERROR=$?
if [ $ERROR -ne 0 ]; then
        echo "Transcoding failed for ${FILENAME} with error $ERROR"
        exit $ERROR
fi
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





More information about the mythtv-users mailing list