Advertisement
Guest User

myth transcode

a guest
Mar 10th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 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. STRTTIM=$4
  8.  
  9. # Should try and get these from settings.php, but for now...
  10. DATABASEUSER=mythtv
  11. DATABASEPASSWORD=foo
  12.  
  13. LOGFILE="/var/log/mythtv/mythrokuencode.log"
  14.  
  15. #Added by Krisbee - this is where the commercials are removed and the mpg repacked
  16. #1. Run mythcommflag to convert the commercial flagging to an actual cutlist to remove them
  17. #2. Run mythtranscode to generate a lossless transcode and remove the commercials
  18.  
  19. mythcommflag --chanid $CHANLID --starttime $STRTTIM --gencutlist
  20. mythtranscode --chanid $CHANLID --starttime $STRTTIM --mpeg2 --honorcutlist --outfile $MYTHDIR/$MPGFILE.tmp
  21. mv -f $MYTHDIR/$MPGFILE.tmp /$MYTHDIR/$MPGFILE
  22. rm -f $MYTHDIR/$MPGFILE.tmp.map
  23.  
  24. newbname=`echo $MPGFILE | sed 's/\(.*\)\..*/\1/'`
  25. newname="$MYTHDIR/$newbname.mp4"
  26.  
  27. echo "Roku Encode $MPGFILE to $newname, details in $LOGFILE" >> $LOGFILE
  28.  
  29. date=`date`
  30. echo "$newbname:$date Encoding" >> $LOGFILE
  31. #/usr/bin/HandBrakeCLI -i $1/$2 -o $newname -e x264 -b 1500 -E faac -B 256 -R 48 -w 720
  32. #/usr/bin/HandBrakeCLI -i $MYTHDIR/$MPGFILE -o $newname -e x264 -r 29.97 -b 1500 -E faac -B 256 -R 48 --decomb >> $LOGFILE 2>&1
  33. #/usr/bin/HandBrakeCLI --preset='iPhone & iPod Touch' -i $MYTHDIR/$MPGFILE -o $newname >> $LOGFILE 2>&1
  34. /usr/bin/HandBrakeCLI --preset='High Profile' -l 720 -b 2000 -i $MYTHDIR/$MPGFILE -o $newname >> $LOGFILE 2>&1
  35.  
  36. date=`date`
  37. echo "$newbname:$date Previews" >> $LOGFILE
  38. #Mythtv seems to have problems with keyframes in mp4s, so make previews with ffmpeg
  39. # ffmpeg -loglevel quiet -ss 00:05:09 -vframes 1 -i $newname -y -f image2 $MYTHDIR/$newbname.mp4.png >> $LOGFILE 2>&1
  40. # ffmpeg -loglevel quiet -ss 00:05:09 -vframes 1 -i $newname -y -f image2 -s 100x75 $MYTHDIR/$newbname.mp4.64.100x75.png >> $LOGFILE 2>&1
  41. # ffmpeg -loglevel quiet -ss 00:05:09 -vframes 1 -i $newname -y -f image2 -s 320x240 $MYTHDIR/$newbname.mp4.64.320x240.png >> $LOGFILE 2>&1
  42. #ffmpeg -loglevel quiet -ss 34 -vframes 1 -i $newname -y -f image2 -s 100x75 $MYTHDIR/$newbname.jpg >> $LOGFILE 2>&1
  43.  
  44. date=`date`
  45. echo "$newbname:$date Database/remove" >> $LOGFILE
  46. # remove the orignal mpg and update the db to point to the mp4
  47. NEWFILESIZE=`du -b "$newname" | cut -f1`
  48. echo "UPDATE recorded SET basename='$newbname.mp4',filesize='$NEWFILESIZE',transcoded='1' WHERE basename='$2';" > /tmp/update-database.sql
  49. mysql --user=$DATABASEUSER --password=$DATABASEPASSWORD mythconverg < /tmp/update-database.sql
  50. rm $MYTHDIR/$MPGFILE
  51.  
  52. echo "Updating Seektable so you can fast forward in Myth" >> $LOGFILE
  53. mythcommflag --rebuild --file $newname
  54.  
  55. # Make the bif files for trick play
  56. # cd $MYTHDIR
  57. # If it's HD we assume it's 16:9
  58. # date=`date`
  59. echo "$newbname:$date makebif HD" >> $LOGFILE
  60. # /usr/local/bin/makebif.py -m 3 $newname >> $LOGFILE 2>&1
  61. # If it's SD we assume it's 4:3
  62. # date=`date`
  63. # echo "$newbname:$date makebif SD" >> $LOGFILE
  64. # /usr/local/bin/makebif.py -m 0 $newname >> $LOGFILE 2>&1
  65.  
  66. date=`date`
  67. echo "$newbname:$date Complete" >> $LOGFILE
  68. echo "" >> $LOGFILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement