Created
February 3, 2023 09:59
-
-
Save benjaminbellamy/fa7ac3d55ba21aad5cf09fa79a6959d8 to your computer and use it in GitHub Desktop.
Splits a media file (such as mkv) into flac files, one file per chapter
This file contains hidden or 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/bash | |
# Splits a media file (such as mkv) into flac files, one file per chapter | |
if [[ $# -ne 2 ]] ; then | |
echo 'Syntax: media-to-flac-split.sh input-file.mkv stream-number' | |
exit 1 | |
fi | |
DIRECTORY="${1//[\. \"\']/-}-stream-$2" | |
mkdir -p $DIRECTORY | |
ffprobe -i $1 2>&1 | grep "Chapter #" | sed -E "s/ *Chapter #[0-9]+.([0-9]+): start ([0-9]+.[0-9]+), end ([0-9]+.[0-9]+)/-map 0:$2 -ss \2 -to \3 -metadata track=\"\1\" $DIRECTORY\/track-\1.flac/" | xargs ffmpeg -y -i $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment