1
0
mirror of https://github.com/dpsenner/mkv-split-chapters.git synced 2025-12-09 23:47:21 +01:00
Files
mkv-split-chapters/mkv-split-chapters.sh
Dominik Psenner a692c17231 Initial import
2017-07-25 19:18:50 +02:00

27 lines
772 B
Bash
Executable File

#!/bin/bash
file="$1"
if [ -z "$file" ]; then
echo "Missing file argument!"
exit 1
fi
filename=$(basename "$file")
fileextension="${filename##*.}"
filename="${filename%.*}"
filedir=$(dirname "$file")
echo "Filename: $filename"
echo "Extension: $fileextension"
echo "Filedir: $filedir"
ffmpeg -i $file 2>&1 | grep 'Chapter' | grep 'start' | grep ', end' | awk "{
chapter=\$2
# replace : with nil
gsub(/:/, \"\", chapter)
start=\$4
# remove everything but 0-9.
gsub(/[^0123456789\.]/, \"\", start)
end=\$6
command=sprintf(\"ffmpeg -i $file -ss %s -to %s -acodec copy -vcodec copy $filedir/$filename-%s.$fileextension\n\", start, end, chapter)
print(command)
system(command)
}"