jfabernathy

Mythtranscode.sh-original

Nov 29th, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #convert mpeg file to mp4 using handbrakecli
  4. MYTHDIR=$1
  5. MPGFILE=$2
  6. CHANLID=$3
  7. STRTTIMUTC=$4
  8.  
  9. # Should try and get these from settings.php, but for now...
  10. DATABASEUSER=mythtv
  11. DATABASEPASSWORD=PASSWORD
  12. DATABASEHOST=localhost
  13.  
  14. LOGFILE="/var/log/mythrokuencode/mythrokuencode.log"
  15.  
  16. newbname=`echo $MPGFILE | sed 's/\(.*\)\..*/\1/'`
  17. newname="$MYTHDIR/$newbname.mp4"
  18.  
  19. echo "Roku Encode $MPGFILE to $newname, details in $LOGFILE" >> $LOGFILE
  20.  
  21. date=`date`
  22. echo "$newbname:$date Encoding" >> $LOGFILE
  23. /usr/bin/HandBrakeCLI --preset='Roku 720p30 Surround' -i $MYTHDIR/$MPGFILE -o $newname >> $LOGFILE 2>&1
  24.  
  25. date=`date`
  26. echo "$newbname:$date Database/remove" >> $LOGFILE
  27. # remove the orignal mpg and update the db to point to the mp4
  28. NEWFILESIZE=`du -b "$newname" | cut -f1`
  29. echo "UPDATE recorded SET basename='$newbname.mp4',filesize='$NEWFILESIZE',transcoded='1' WHERE basename='$2';" > /tmp/update-database.sql
  30. mysql --user=$DATABASEUSER --password=$DATABASEPASSWORD --host=$DATABASEHOST -D mythconverg < /tmp/update-database.sql
  31. rm -f $MYTHDIR/$MPGFILE
  32. rm -f $MYTHDIR/$MPGFILE.old
  33.  
  34. date=`date`
  35. echo "$newbname:$date Previews" >> $LOGFILE
  36.  
  37. # Mythpreviewgen seems to have no issues with previews, so running it
  38. mythpreviewgen --infile $newname >> $LOGFILE 2>&1
  39.  
  40.  
  41. echo "Deleting Seektable so you can fast forward in Myth" >> $LOGFILE
  42. mythutil --clearseektable --chanid $CHANLID --starttime $STRTTIMUTC
  43.  
  44. date=`date`
  45. echo "$newbname:$date Complete" >> $LOGFILE
  46. echo "" >> $LOGFILE
Add Comment
Please, Sign In to add comment