jfabernathy

mythtranscode.sh-myversion

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