Posted by Brian @ 12:45 pm on August 14th 2011

Remove audio compression from all .mkv videos, including subdirectories

A while back I wrote about audio compression causing a black screen of death on my WD TV HD player with a one-line fix to the problem.

I have an improved solution. I wrote a quick BASH script that scans all the videos it finds in the Matroska (.mkv) format in the current directory as well as any subdirectories it finds, removing all compression from .mkvs it finds and saving a new mkv with “fixed” appended to the filename.

# This script will traverse all subdirectories looking for Matroska (.mkv) files
# When an .mkv file is found, it will be checked for compression
# If compression is found, create a new file without compression with "-fixed" added to name
# (e.g. badmovie.mkv -> badmovie-fixed.mkv)
# Run from the root directory that you want to begin scanning from (e.g. /home/foo/Videos or /media/USBdrive)
# 1/22/2012 v2
# better handling for files with spaces; removes all compression, not just track 1
# remove the need for a command line parameter
echo $start
find -type d | while read directory
cd "$start${directory#"./"}"
for file in *.mkv
if mkvinfo "$file" | grep ompress > /dev/null
cut_len=$(($file_len - 4))
fixedfile=${prefixedfile// /.}
mkvmerge -o "$fixedfile" --compression -1:none "$file"
if mkvinfo $fixedfile | grep compression > /dev/null
echo "$fixedfile still has issues"
cd ..

Note, I edited this post on 1/22/12 with the current version of this script which handles filenames with spaces and removes all compression, not just the first track.


  1. is this a program i can download?

    Comment by brian smith — October 25, 2011 @ 11:39 pm

  2. Not exactly, it’s a BASH script for Linux. Something like this is probably possible on Windows or Mac but I have no idea how.

    Comment by Brian — November 6, 2011 @ 1:12 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.