Created
January 11, 2021 00:34
-
-
Save antonalekseev/d4f7ae1d360c6a4573a55adeb38caf0c to your computer and use it in GitHub Desktop.
Split audiobook into files containing individual chapters
This file contains hidden or 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: Modified version of script from https://unix.stackexchange.com/a/612124 | |
| # 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.m4a" | |
| 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