[mythtv-users] Automatically Transcoding the Commercials Away

Dwight Hubbard dwight at dwightandamy.com
Mon Feb 11 20:57:45 UTC 2008


I have a python script I've been playing with to do this kind of
thing.  It is a "works for me" kind of script but you're welcome to
look at it.  I did a blog entry for the most recent version at
http://computing.dwighthubbard.info/index.php/2008/02/11/mythtv-cropborders-script-has-been-updated-and-renamed/

On Feb 5, 2008 8:25 PM, Eric Mesa <ericsbinaryworld at gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I've been reading the code provided in the wiki and I just wanted to
> make sure I was doing things correctly before potentially messing up my
> files and/or database.  I have a row of hashes (#) where I'm going to
> change up the script.
>
>
> #!/bin/sh
> VIDEODIR=$1
> FILENAME=$2
> # 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.
>
> #I want to delete this section since I already commercial flag all of my
> recordings and will only
> #transcode certain ones
> #######################################################################################3
> 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 --honorcutlist --showprogress -i $VIDEODIR/$FILENAME -o
> $VIDEODIR/$FILENAME.tmp
> ERROR=$?
> if [ $ERROR -ne 0 ]; then
> ~        echo "Transcoding failed for ${FILENAME} with error $ERROR"
> ~        exit $ERROR
> fi
> #I if I just want to overwrite the original files w/o saving this .old
> file, do I just remove this next line?
> ############################################################################################################
> 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
> #I added this since I have auto-commercial skip enabled
> ##########################################################################
> DELETE FROM
> ~       `recordedmarkup`
> WHERE
> ~       CONCAT( chanid, starttime ) IN (
> ~               SELECT
> ~                       CONCAT( chanid, starttime )
> ~               FROM
> ~                       recorded
> ~               WHERE
> ~                       basename = '$FILENAME'
> ~       );
> #############################################################################
> 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
>
>
>
> Also, once this is all put into a file - do I put it into /usr/local/bin
> ?  And how do I run it as a user job?
>
> Thanks!
>
> - --
> Eric Mesa
> ericsbinaryworld at gmail.com
> http://www.ericsbinaryworld.com
> Note:  All emails from this address should have a GPG signature.  If you
> have the proper setup you can use this to confirm my identity and that
> the email was not changed in transit.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
>
> iD8DBQFHqTbBPvU+8ApmWXIRAh6ZAJ0UOJe2/UBCywbL2ico08fYGHKIjQCfY6D8
> bSSKIzcQSMxAGIjnxU1qHQk=
> =NRYa
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>



-- 
Dwight Hubbard (RHCE, VCP)
dwight at dwighthubbard.com
http://computing.dwighthubbard.info


More information about the mythtv-users mailing list