A “two steps HOWTO” to fix your broken Matroska file.
Downloading High Definition(HD, 720p, 1080p, x264 encoded) content via torrent or other isn’t unusual nowadays anymore. Unfortunately such content is very big in size, and you have sometimes to wait a very long time until your latest serial has completely hit your hard disk drive. Sometimes it happens the only available source is an archive file (.rar) and you have to unrar it first, before you can watch it. And sometimes you encounter also this message on unpacking it:
unrar x filename.rar
Extracting filename.mkv 99%
filename2.avi - CRC failed
Total errors: 1
If this happens, you already know, the content isn’t in a good shape, and you just hope there are just a few unimportant bytes missing. So you unpack it again with the “-kb” switch of the unrar command, to keep the broken file (keep broken) on your hard disk:
unrar x -kb filename.rar
Here I thought, it would be wise to try to repair the broken rar-archive first (
rar r filename.rar), but it turned out, that the result remains the same, and you have again to choose the “-kb” switch, else the files won’t be written onto your disk, and nothing in fact is really repaired, unless your archive posses a recovery record, which had have to be created with the “-rr[N]” switch before. I’m not an expert on that, but I’ve never encountered such a record in the wild.
So OK, what now?
Here you are now with the broken Matroska video file, and mplayer crashes after a few minutes playing. What if one could repair the broken stream? I mean, you won’t get broken video information back, if they aren’t there, you won’t see this sequence anymore, it’s gone for ever. But what if it’s just a broken container (.mkv) and only just a few frames are missing. Then it should be worth to fix the broken video file.
I’ve found a possibility to repair broken Matroska (.mkv) files with free Linux tools. What you need is a current mkvtoolnix package.
Ubuntu 8.10 provides mkvtoolnix version 2.0.2, which very likely won’t work, since there is a very ugly bug in it. Chance is high you’ll see this error:
Error: '23,976fps' is not a valid default duration in '--default-duration 23,976fps'.
if your footage is not 25 frames/second (fps), what is also very likely! Read below how to get a current version (2.4.0), it’s quite easy.
[UPDATE 2008-12-07] Intrepid Ibex (8.10) provides now mkvtoolnix version 2.4.1. Just skip the step with installing new mkvtoolnix part. Just perform on your system an ‘
apt-get update && apt-get upgrade‘, and follow the instruction here.
Ok – let’s go:
Installing MKVToolnix on a Ubuntu 8.10 (Intrapid Ibex):
- Insert these lines into your
deb http://www.bunkus.org/ubuntu/intrepid/ ./
deb-src http://www.bunkus.org/ubuntu/intrepid/ ./
- perform a
aptitude install mkvtoolnix
something like this should return:
mkvinfo v2.4.0 ('Fumbling Towards Ecstasy') built on Nov 4 2008 00:30:11
Verify the version number of the mkvtoolnix application with this command:
Check this site for your Linux distribution, it’s a really good archive, and the chance is high your .deb/.rpm binaries are also available for your distro.