Skip to content

Instantly share code, notes, and snippets.

@tzkmx
Created April 14, 2023 02:25
Show Gist options
  • Save tzkmx/84bc2950309a59f91387eaa262b39e43 to your computer and use it in GitHub Desktop.
Save tzkmx/84bc2950309a59f91387eaa262b39e43 to your computer and use it in GitHub Desktop.
Script to split by chapters and convert audible to mp3.
#!/bin/sh -efu
input="$1"
ffprobe \
-print_format csv \
-show_chapters \
"$input" |
cut -d ',' -f '5,7,8' |
while IFS=, read start end chapter
do
ffmpeg \
-nostdin \
-loglevel error \
-y -activation_bytes "$2" \
-ss "$start" -to "$end" \
-i "$input" \
-metadata "track=$chapter" \
-map 0:a:0 \
-codec:a libmp3lame \
-map_chapters -1 \
"${input%.*}-$chapter.mp3"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment