Created
December 6, 2022 16:12
-
-
Save spoterianski/89554319988952fdfc562a62f76c283a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Description: Split an m4b into its chapters. No recoding is done, just splitting | |
# Usage: m4b_split.sh $input_file $output_dir/ | |
# Requires: ffmpeg, jq | |
# Author: Hasan Arous, Sergey Poterianski | |
# License: MIT | |
in="$1" | |
out="$2" | |
splits="" | |
c=0 | |
while read -d'|' start end title; do | |
let "c=c+1" | |
cs=`printf %02d $c` | |
splits="$splits -map 0:a -c:a libmp3lame -filter:a atempo=1.25 -ss $start -to $end $out/${cs}_${title}.mp3" | |
done <<<$(ffprobe -i "$in" -print_format json -show_chapters \ | |
| jq -r '.chapters[] | .start_time + " " + .end_time + " " + (.tags.title | gsub(" "; "_")) + "|"') | |
#echo $splits | |
ffmpeg -i "$in" $splits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment