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
- # Should try and get these from settings.php, but for now...
- DATABASEUSER=mythtv
- DATABASEPASSWORD=PASSWORD
- DATABASEHOST=localhost
- LOGFILE="/var/log/mythrokuencode/mythrokuencode.log"
- newbname=`echo $MPGFILE | sed 's/\(.*\)\..*/\1/'`
- newname="$MYTHDIR/$newbname.mp4"
- echo "Roku 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='$2';" > /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.old
- 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
Add Comment
Please, Sign In to add comment