iconoclasthero

chaptersplit 2022.02.26

Feb 26th, 2022 (edited)
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.38 KB | None | 0 0
  1. #!/bin/bash
  2. # Original code from: http://crunchbang.org/forums/viewtopic.php?id=38748#p414992
  3. # m4bronto
  4.  
  5. #     Chapter #0:0: start 0.000000, end 1290.013333
  6. #       first   _     _     start    _     end
  7.  
  8. scriptname="$(realpath $0)"
  9. title="title"
  10. #The Ascent of Money"
  11. #Principles for Dealing with the Changing World Order"
  12. #Capital and Ideology"
  13. stamp=$(date +%s)
  14.  
  15. function editscript(){
  16. echo "scriptname: $scriptname"
  17. if [[ "$1" == "edit" ]]; then
  18.  (/usr/bin/nano "$scriptname")
  19.  exit
  20. fi
  21. }
  22.  
  23. function pause(){
  24.    read -p "$*"
  25. }
  26.  
  27. editscript "$1"
  28.  
  29. while [ $# -gt 0 ]; do
  30.  
  31. ffmpeg -i "$1" 2> ".tmp$stamp"
  32.  
  33. while read -r first _ _ start _ end; do
  34.   if [[ $first = Chapter ]]; then
  35.     read  # discard line with Metadata:
  36.     read _ _ chapter
  37. #    ffmpeg -nostdin -activation_bytes <bytes> -vsync 2 -i "$1" -ss "${start%?}" -to "$end" -vn -b:a 17k -acodec libopus "$title -- $chapter.opus" </dev/null
  38. #    ffmpeg -n -nostdin -hide_banner -stats -vsync 2 -i "$1" -filter_complex "compand=attacks=0:decays=0.12:points=-70/-900|-40/-90|-35/-37|-21/-18|1/-1|20/-1:soft-knee=0.03:gain=1.00:volume=-90, firequalizer=gain_entry='entry(0,-99);entry(140,0);entry(1000,0);entry(8000,1);entry(10500,4);entry(12000,5);entry(14500,-4);entry(19000,-20)', volume=1.0" -ss "${start%?}" -to "$end" -vn -b:a 17k -acodec libopus "$title -- $chapter.opus" </dev/null
  39. ###copy:
  40.     ffmpeg -n -nostdin -hide_banner -stats -vsync 2 -ss "${start%?}" -to "$end" -i "$1" -vn -codec copy "$title -- $chapter.opus" </dev/null
  41. ###convert:
  42. #ffmpeg -n -nostdin -activation_bytes <bytes> -hide_banner -stats -vsync 2 -filter_complex "compand=attacks=0:decays=0.12:points=-70/-900|-40/-90|-35/-37|-21/-18|1/-1|20/-1:soft-knee=0.03:gain=1.00:volume=-90, firequalizer=gain_entry='entry(0,-99);entry(140,0);entry(1000,0);entry(8000,1);entry(10500,4);entry(12000,5);entry(14500,-4);entry(19000,-20)', volume=1.0" -ss "${start%?}" -to "$end" -i "$1" -vn -b:a 17k -acodec libopus "/dev/shm/cache/$title -- $chapter.opus" </dev/null
  43.  
  44.  
  45.   fi
  46. done <".tmp$stamp"
  47.  
  48. rm ".tmp$stamp"
  49.  
  50. shift
  51. done
  52.  
  53. for i in "$title -- Chapter "?.opus;
  54.  do
  55.   mv "$i" "${i/Chapter /Chapter 0}";
  56.  done
  57.  
  58. if [ -n "$1" ];
  59.  then
  60.   echo mediaduration "${1#*.}" `mediaduration "${1#*.}"`
  61.   echo mediaduration opus `mediaduration opus`
  62.  else
  63.   echo mediaduration "${file#*.}" `mediaduration "${file#*.}"`
  64.   echo mediaduration opus `mediaduration opus`
  65. fi
  66.    
Add Comment
Please, Sign In to add comment