Skip to content

Instantly share code, notes, and snippets.

@koonix
Created September 10, 2022 21:29
Show Gist options
  • Save koonix/75d6b0f5dedc405030884593df8bf6f6 to your computer and use it in GitHub Desktop.
Save koonix/75d6b0f5dedc405030884593df8bf6f6 to your computer and use it in GitHub Desktop.
split the given video/audio files by chapters using ffmpeg.
#!/bin/sh -efu
# split the given video/audio files by chapters using ffmpeg.
for file; do
ffprobe -print_format csv -show_chapters -- "$file" | cut -d, -f5,7,8 |
while IFS=, read start end chapter; do
ffmpeg -hide_banner -nostdin -ss "$start" -to "$end" -i "$file" \
-c copy -map 0 -map_chapters -1 -- "${file%.*}-$chapter.${file##*.}"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment