Skip to content

Instantly share code, notes, and snippets.

@janw
Created December 5, 2022 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janw/c7b9db6c3dfe11d449e808a06e85cfc5 to your computer and use it in GitHub Desktop.
Save janw/c7b9db6c3dfe11d449e808a06e85cfc5 to your computer and use it in GitHub Desktop.
Disable forced subtitles in MKV files
#!/usr/bin/env bash
set -euo pipefail
files=("$@")
function disable_subs() {
local file=$1
local forced_track_id
forced_track_id="$(mkvmerge -J "$file" |
jq -r '
.tracks[]
| select(.type=="subtitles" and .properties.forced_track)
| .properties.number
')"
if [ -z "$forced_track_id" ]; then
echo "No forced track. Skipping."
return
fi
mkvpropedit "$file" \
--edit "track:@${forced_track_id}" \
--set flag-forced=0
}
for file in "${files[@]}"; do
echo "Processing $file ..."
if [ ! -f "$file" ]; then
echo "File does not exist. Skipping."
continue
fi
disable_subs "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment