1
0
mirror of https://github.com/dpsenner/mkv-split-chapters.git synced 2025-12-09 23:47:21 +01:00

Initial import

This commit is contained in:
Dominik Psenner
2017-07-25 19:18:50 +02:00
parent 312b998131
commit a692c17231

26
mkv-split-chapters.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/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)
}"