Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #convert mpeg file to mp4 using handbrakecli
- MYTHDIR=$1
- MPGFILE=$2
- CHANLID=$3
- STRTTIMUTC=$4
- #
- # add this command line to mythtv backend jobs in setup
- # /usr/local/bin/mythtranscode.sh "%DIR%" "%FILE%" "%CHANID%" "%STARTTIMEUTC%"
- #
- # Should try and get these from settings.php, but for now...
- DATABASEUSER=mythtv
- DATABASEPASSWORD=wNzo637fW70rjn+p
- DATABASEHOST=localhost
- LOGFILE="/tmp/mythrokuencode.log"
- newbname=`echo $MPGFILE | sed 's/\(.*\)\..*/\1/'`
- newname="$MYTHDIR/$newbname.mp4"
- echo "Encode $MPGFILE to $newname, details in $LOGFILE" > $LOGFILE
- date=`date`
- echo "$newbname:$date Encoding" >> $LOGFILE
- /usr/bin/HandBrakeCLI --preset='Roku 720p30 Surround' -i $MYTHDIR/$MPGFILE -o $newname >> $LOGFILE 2>&1
- date=`date`
- echo "$newbname:$date Database/remove" >> $LOGFILE
- # remove the orignal mpg and update the db to point to the mp4
- NEWFILESIZE=`du -b "$newname" | cut -f1`
- echo "UPDATE recorded SET basename='$newbname.mp4',filesize='$NEWFILESIZE',transcoded='1' WHERE basename='$MPGFILE';" > /tmp/update-database.sql
- mysql --user=$DATABASEUSER --password=$DATABASEPASSWORD --host=$DATABASEHOST -D mythconverg < /tmp/update-database.sql
- rm -f $MYTHDIR/$MPGFILE
- rm -f $MYTHDIR/$MPGFILE.png
- date=`date`
- echo "$newbname:$date Previews" >> $LOGFILE
- # Mythpreviewgen seems to have no issues with previews, so running it
- mythpreviewgen --infile $newname >> $LOGFILE 2>&1
- echo "Deleting Seektable so you can fast forward in Myth" >> $LOGFILE
- mythutil --clearseektable --chanid $CHANLID --starttime $STRTTIMUTC
- date=`date`
- echo "$newbname:$date Complete" >> $LOGFILE
- echo "" >> $LOGFILE
Advertisement
Add Comment
Please, Sign In to add comment