]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/bash/ffmpeg-split.sh
praat: install in science profile
[julm/julm-nix.git] / home-manager / profiles / bash / ffmpeg-split.sh
1 #!/usr/bin/env bash
2 set -efu
3
4 input="$1"; shift
5 ffprobe -print_format csv -show_chapters "$input" |
6 cut -d ',' -f '5,7,8' |
7 while IFS=, read -r start end chapter; do
8 ffmpeg \
9 -nostdin \
10 -ss "$start" -to "$end" \
11 -i "$input" \
12 -c copy \
13 -map 0 \
14 -map_chapters -1 \
15 "$@" \
16 "$(printf %s "${input%.*}.$chapter.${input##*.}" | tr / _ | sed -e "s/\.\./_/g")"
17 done