Xyberviri

iso2mkv.sh

Jun 23rd, 2017
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. if [ -z $1 ]; then
  4.  echo "no file given"
  5. exit 0
  6. fi
  7.  
  8. if [ -z $2 ]; then
  9.     outFilePrefix="$(echo $1 | sed 's=.*/==;s/.iso//I')"
  10. else
  11.     outFilePrefix=$2
  12. fi
  13.  
  14. if [ -z $3 ]; then
  15.     outTitleOffset=1
  16. else
  17.     outTitleOffset=$3
  18. fi
  19.  
  20. rawout=$(HandBrakeCLI --min-duration 0 -i $1 -t 0 2>&1 >/dev/null)
  21. count=$(echo $rawout | grep -Eao "\\+ title [0-9]+:" | wc -l)
  22.  
  23. echo $count
  24. echo $rawout | grep -Eao "\\+ duration: [0-9]+:[0-9]+:[0-9]+"
  25.  
  26. for i in $(seq $count)
  27. do
  28.     title=$(printf "%02d" $outTitleOffset)
  29.     ((outTitleOffset++))
  30.     echo -e "\n\n\nExtracting title $i as '${outFilePrefix}${title}.mkv'\n\n\n"
  31.     HandBrakeCLI -i $1 -t $i --preset Normal --output ${outFilePrefix}${title}.mkv
  32. done
  33.  
  34. echo -e "\n\n\niso2mkv complete!"
  35.  
  36.  
  37. #prereqs:
  38. #sudo add-apt-repository ppa:stebbins/handbrake-releases
  39. #sudo apt-get update
  40. #apt-get install handbrake-cli libdvdcss2
  41.  
  42. #It's worth noting that if you want that count value to be right you'll need to pass --min-duration 0
  43. #to HandBrakeCLI otherwise you'll come up short on some DVDs.
  44. #default is the track length needs to be >10 seconds
  45. #https://handbrake.fr/docs/en/1.0.0/cli/cli-guide.html
  46. #version 2 of this script: https://pastebin.com/SRHihAED
Advertisement
Add Comment
Please, Sign In to add comment