Created
December 5, 2022 19:54
-
-
Save janw/c7b9db6c3dfe11d449e808a06e85cfc5 to your computer and use it in GitHub Desktop.
Disable forced subtitles in MKV files
This file contains 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
#!/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