Skip to content

Instantly share code, notes, and snippets.

@Neolot
Created May 1, 2024 14:18
Show Gist options
  • Save Neolot/3bdb3d9d7b79d4e36a336f22341d1cbd to your computer and use it in GitHub Desktop.
Save Neolot/3bdb3d9d7b79d4e36a336f22341d1cbd to your computer and use it in GitHub Desktop.
LINUX Extract track from MKV
#!/usr/bin/sh
file=$1
if [ -z "$file" ]; then
echo "USAGE: extract_mkv_track.sh <filename>"
exit 1;
fi
extension="${file##*.}"
if [ "$extension" != "mkv" ]; then
echo "The file is not an MKV video."
exit 1;
fi
# Display available tracks
echo "Available tracks:"
mkvmerge -i "$file"
# Ask the user to choose a track
echo "Enter the track number to extract (ex. 10:track_name.ac3):"
read -r track_number
# Extract the track
mkvextract tracks "$file" "$track_number"
echo "Track has been saved."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment