8838efe63d3e8f39c03fe9e356d76dc22004132b
2 # Desc: Split an audio file by chapter
4 # Ref/Attrib: [1] Hasan Arous. MIT license. https://unix.stackexchange.com/a/612124
5 # [2] John Smith. https://unix.stackexchange.com/a/712600
11 while read start end title
; do
12 newTitle
="$(echo "$title" | sed "s
/ /_
/g
")";
13 newTitle
="$(printf "%02d..
%s
" "$n" "$newTitle")";
14 splits
="$splits -c copy -ss $start -to $end $out/$newTitle.m4b";
16 done <<< $
(ffprobe
-i "$in" -print_format json
-show_chapters \
17 | jq
-r '.chapters[] | .start_time + " " + .end_time + " " + (.tags.title | sub(" "; "_"))');
18 ffmpeg
-i "$in" $splits;
20 # Author: Steven Baltakatei Sandoval