AfterDawn.com

Repair broken or corrupt AVI files


Do you have a problematic AVI file? Well you have come to the right place. This brief article runs through a few things you can try with a corrupt AVI file to see if you can make it work properly. Please note this is not a guide to fixing lip-sync on AVI files (look here for that), this is instead for AVI files that have bad artifacts appearing on screen, don't play at all or other problems.

Follow the Guide Author on Twitter: jamesdela@twitter

Introduction & Requirements


Software you must download and install
DivFix++
Optional: DivFix++ is used in this guide, but it is not a definite necessity. It is still recommended that you download this tool anyway. Download!
DivXRepair
Optional: DivXRepair is used in this guide, but it is not a definite necessity. It is still recommended that you download this tool anyway. Download!
VirtualDUBMOD
Optional: VirtualDUBMOD is used in this guide, but it is not a definite necessity. It is still recommended that you download this tool anyway. Download!

There are three software items listed for this guide. None of them are a definite necessity however, they are simply sampled in this article as a possible fix for a bad AVI file. Therefore, you do not need to download them all, but it wouldn't hurt to hoard some video tools for future usage anyway.

What kind of problems might you encounter, and why?


There are several different types of problems you might have with an AVI file..
  1. AVI File will not play in anything -> If it happens to be the case that your AVI file simply will not work with anything you try, then it could be a codec issue. You need a codec to decode the video and audio data within an AVI file.
  2. Sound but no picture -> This problem is also associated with codec problems.
  3. Picture but no sound -> This problem is also associated with codec problems.
  4. Picture freezes but sound continues -> Possibly broken/corrupted frames in the video stream.
  5. Picture gets pixilated and blocky -> Possibly due to corrupted frames.
  6. Cannot seek/skip through video -> This is often due to a bad AVI Index, or a lack of an Index entirely.
  7. Audio is out of sync -> Often due to a badly prepared file (different length for video and audio streams, for example). This problem can be worked-around with software players or fixed permanently in cases, but that is not covered in this guide. Check here for sync information.

AVI Sound, Video or Both do not work


If it is the case that your AVI file simply will not work in a player you have tried it in, you might just lack a necessary codec for the video or audio data in the AVI. If that is the case, then the file is probably not corrupted and so it is not covered in-depth in this guide. However, here are some quick options you can choose to take, if you so wish.
  • Find the codecs required to play your AVI file -> I would submit that the best solution to a codec problem would be to find out exactly what codecs your AVI file requires. AviCodec is the best option for this (Download it Now!). With AviCodec, you can simply load in an AVI file and it will tell you what video and audio codecs you require for each stream. Please note that if AviCodec cannot read anything from a file, then it could potentially be a fake (from P2P perhaps?). Read our guide, "What codecs to use? The AVIcodec guide" for more in-depth information.

  • Shotgun Approach, Install FFDShow --> If you would rather not bother to go checking what codecs you need to Install, and would instead prefer to just download a tool and click Next a few times, then you can always use the brilliant FFDShow (Download it Now!). FFDShow is a pack of decoders for all types of multimedia content. It is totally free and it works very well even on low-resource PCs.

Possible Fix for many problems: Rebuild AVI with VirtualDUBMOD




When it comes to AVI tools, VirtualDUBMOD is truly a swiss-army knife. VirtualDUBMOD allows you to splice, split, mux, demux, merge etc. AVI files and loads of more advanced operations.. and its free too. Even better, VirtualDUBMOD can also find problems with AVI files quickly and can be used to simply re-save an AVI file (which helps a lot, especially with AVI problems on Xbox 360).

The picture shown above is a typical warning message you would receive from VirtualDUBMOD for a corrupted AVI file. As you can see from reading it, VirtualDUBMOD basically fixes the issues itself automatically; all you really need to do is re-save the file. To do that, you need to do the following...

Re-save AVI File




Open an AVI File in VirtualDUBMOD using the File menu. If you received possible errors when it opened, there is potentially an easy solution to your problem; re-saving an AVI file. This works because an AVI file simply "contains" video and audio streams (as well as some others). Hence the reason why an AVI is actually a container file. If the information the AVI file stores on the streams it contains is incorrect in some way, this can result in playback problems. VirtualDUBMOD is excellent when it comes to saving video and audio streams to the AVI container.

Once the file is opened, you need to make sure the video and audio will be saved "as is". Click Video and select "Direct Stream Copy". This is vital - if you forget this, it will save uncompressed video and take up gigabytes of space. The default setting for audio is already Direct Stream Copy, so you do not need to worry about that.

Now it's time to save.



Click File - Save AVI. When the folder browser loads, navigate to a location to save your new AVI file, give it a name and click Save. With Direct Stream Copy selected for video, this should take no longer than a couple of minutes. This may fix the problem you experience with your AVI file.

Possible Sound Fix: Re-encode audio with VirtualDUBMOD




Some sound problems can be fixed by simply re-encoding audio. Please note that by now, if you have sound problems, you should have ruled out a missing codec as the reason. If you haven't, then please go back up the page and do so. Most AVI files will contain MP3 audio. If this is VBR audio, then you will get the message above when you open it in VirtualDUBMOD. For this part of the guide, open your file and select "No" as the answer to this question (if you get it).

Now you need to do the same as the"Re-save AVI" instructions just above, except this time you will need to set audio to "Full Processing Mode". DO NOT FORGET to set video to "Direct Stream Copy" again, unless you want a multi-gigabyte resulting file that takes potentially hours to finish. After setting the Video to Direct Stream Copy (as shown above in the Re-save instructions), click Streams --> Stream List.



When you see the audio stream for your AVI file, right click on it (as shown above) and set it to "Full Processing Mode". After you have set it to Full Processing Mode, you should now be able to click Compression when you right click it again.



From the left pane, choose Lame MP3 (if it is not present in your VirtualDUBMOD, then see just below for instructions on adding it). Then on the right, select 48000 Hz, 192 kbps CBR, Stereo, or better. When done, click OK.

NOTE: If Lame MP3 is not available as a compression, then you must install the Lame MP3 ACM Codec. You can download it from here. When you download the ZIP archive, open it in Windows Explorer or extract it to a folder with WinRAR, then right-click on LameACM.inf and select Install from the list. It will now be available for use with VirtualDUBMOD once you restart the program.

No go ahead and save the file. This time it will take longer to save than before, because the audio will be encoded again. Hopefully this will resolve an audio problem for you. If none of these methods worked, then it means VirtualDUB re-saving was not capable of fixing your problem. That leaves codec issues (which you should have already resolved with AviCodec or FFDShow) or broken video or audio streams as the potential culprits. For that, there are two other tools you can use, DivFix++ and DivXRepair.

DivFix++




DivFix++ will allow you to do a number of things to an AVI file. It has a number of tricks up its sleeve when it comes to AVI files. A lot of AVI problems are associated with the Index for example; DivFix++ can Strip the Index with the click of a button and then rebuild it while running a Fix. It can also scan the file for other errors it is built to detect.

Open AVI files in DivFix




To open AVI files in DivFix, simply click Add Files and search for all the AVI files you want to attempt to fix. Once they appear in the list, clicking them will bring up information on them in the Log Window that you might find useful.

Fixing an AVI File with DivFix




If your problem is simply that you cannot skip (seek) through an AVI file in a player without the video restarting entirely, then you can click Strip Index to remove a potentially corrupt AVI index from the file. Once you click Fix, an accurate index should be built anyway. There are some options that you have to select before you can click fix.
  1. Cut out Bad Parts --> This will literally remove sequences of corrupt frames from the video file if found.
  2. Keep Original File --> DivFix++ creates a new fixed AVI file in the same folder as the original (by default), but you should always keep the original just in case.
  3. Recover from Key Frames --> May potentially take much longer, but recommended if the type of problems you have is progressively worse pixilation and weird colored blockiness on the video stream (particularly green). Selecting this option may help here.
When you have selected all of your options, select Fix.

If you check the new AVI file just to discover that nothing at all has changed, then there is another program left to try; DivXRepair.

DivXRepair




It has to be said that if VirtualDUBMOD and DivFix++ both failed outright to fix the problem, then DivXRepair is not likely to make it any better; but anything is worth a shot if you have exhausted all other possibilities.

Add files and Repair with DivXRepair




Luckily, DivXRepair could not be much simpler to operate. Simply click Add File to add an AVI file to the list. When you have all the AVI files you want to repair added, then click Repair Files. It will now examine every frame in the file for corruption and automatically remove anything bad it finds.

What if all options failed?


Sometimes an AVI file can be notoriously hard to fix. Some problems may be unavoidable completely. One major source of "allegedly" bad AVI files is P2P software such as Limewire, Sky Downloader, Ares etc. Some files are posted only posing as AVI files, but are really just dumby files or something else entirely with an .AVI extension. It is also possible that bad frames are not actually technically "bad", but instead are the products of bad encoding. This could also be the same for audio content.

One other example of an AVI file that I cannot think of an easy way to fix is one that is broken badly from the start of the file. For example, if you receive an AVI file from Usenet or BitTorrent, where the first chunk of the AVI is missing, then it may be impossible for all of the above programs to even recognize the file as an AVI file in the first place.

Almost everybody encounters a broken multimedia file at some point that we simply cannot "fix". The best thing we can do in that situation is look for a fixed file elsewhere with the same content.

Finally


The above methods will fix 95% of all problematic AVI files. I truly hope this will be the case for you. If you want to talk further about broken files or playback / encoding problems, then please visit our Discussion Forums.

Written by: James "Dela" Delahunty
Last updated: 18 December 2009