Last active
March 24, 2017 03:40
-
-
Save 0xquad/145e7c99385e36b04329ffebfc03ecff to your computer and use it in GitHub Desktop.
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/sh | |
# Splits an AV file with multiple chapters into separate files. | |
# Copyright (c) 2017, Alexandre Hamelin <alexandre.hamelin gmail.com> | |
[[ $# -gt 0 ]] || exit 1 | |
file=$1 | |
[[ -f "$file" ]] || exit 2 | |
ext=${file##*.} | |
sub=" *Chapter #([0-9]+.[0-9]+): start ([0-9]+\.[0-9]+), end ([0-9]+\.[0-9]+)" | |
repl="-i \"$file\" -c:v copy -c:a copy -ss \2 -to \3 \"${file%.*}-\1.$ext\"" | |
ffmpeg -i "$file" 2>&1 | | |
sed -r "/Chapter/ {s|$sub|$repl|;p}; d" | head -n 4 | | |
xargs -n 11 ffmpeg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment