Last active
October 27, 2024 05:47
-
-
Save aularon/c48173f8246fa57e9c1ef7ff694ab06f to your computer and use it in GitHub Desktop.
Split an m4b into its chapters. No recoding is done, just splitting
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 | |
# License: MIT | |
in="$1" | |
out="$2" | |
splits="" | |
while read start end title; do | |
splits="$splits -c copy -ss $start -to $end $out/$title.m4b" | |
done <<<$(ffprobe -i "$in" -print_format json -show_chapters \ | |
| jq -r '.chapters[] | .start_time + " " + .end_time + " " + (.tags.title | sub(" "; "_"))') | |
ffmpeg -i "$in" $splits |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great, thanks! 🙏