RisingResearch.com

How to Fix AVI File Manually

07.11.2012

Those processing PC video or just often downloading AVI files, face a situation when the file won't play or plays problematically with video freeze, partial content loss and no fast forward.

Many such problems are solvable by AVI fix software like Digital Video Repair and DivFix++. However, they can't settle some errors. What to do then? Is such video lost or fixable?

File Structure and Its Block Content

To understand why AVI plays problematically, let's consider its structure. Recording AVI data needs the so-called RIFF format dividing the file into separate blocks (chunks). Each chunk consists of a 8-byte title - a 4-symbol ID like RIFF plus 4 bytes informing the software of the data block size inside the chunk. 2 special chunks (RIFF and LIST) also contain an extra (user) ID to form a tree-like data structure. Most other chunks contain only 1 ID and data size. So a standard AVI file structure looks as follows:

AVI Riff Format
AVI Riff Format

In a way, an AVI file consists of 3 parts: a video title written in the LIST/hdrl chunk, the following video itself (a chunk sequence with video frame data and synchronized with it sound chunks - all inside the LIST/movi chunk) and the AVIIndex chunk below.

It may mean the following damage types:

  1. Absence or damage to any chunk title, i.e. either ID change or an incorrect data block size.
  2. Chunk data damage (except its title).
  3. Cases 1 and 2 simultaneously.

AVI fix software normally repairs type 1 & 3 errors due to the abundance of codecs and the problematicity of checking its data correctness. Let's consider possible damage with type 1 (3) errors and its outcome in trying to play such a file.

1. No or a badly damaged AVIIndex chunk

It's responsible for fast forwarding and contains info on each frame data start. This usually happens in 2 cases - the file wasn't fully downloaded or the video recording software failed not to let it fully record the file. In playback it will result in no fast forwarding to the given video fragment. This commonest error is rather easily fixed by AVI repair software as remaining data make it simple to recover this chunk data.

2. Damaged video and audio data in the LIST/movi chunk

It usually happens in 2 cases - a torrent video wasn't fully downloaded (the loose part often fills with stuff like nulls) due to a HDD failure or a badly scratched optical disk with partially readable data. In playback the video usually pauses, skips some fragments with unstable sound depending on video and audio damage scale.

3. No LIST/movi chunk starting audio and video data

It usually goes with a system failure in video recording with the given chunk just partially recorded. The video can't play without defining audio and video data start. Few programs can fix this error.

4. No RIFF/AVI chunk with the next title intact

The reasons are as previous. A video player can't read such a file - "unknown format". It's usually fixed only manually without a RIFF symbol ID. If only the chunk size is misdefined, software will surely repair it.

5. Damaged AVI title (MainAVIHeader) after the RIFF/AVI chunk

The video is unreadable and hardly fixable. The reasons are as in 3 and 4. You can only try to repair it manually.

Errors 3-5 may also happen in (torrent) downloading. Fixing 5 is problematic due to the AVI file title containing info on what video and audio codecs were used in recording which is often unknown when downloading a new file.

Troubleshooting

Such errors are fixable though not always. After failing AVI repair software, use manual processing with a HEX editor like WinHEX or Notepad with a relevant plugin. Open the file in the editor and to fix error 4, type the 1st 4 bytes with RIFF, skip next 4 bytes and fill next 4 bytes with AVI and a space.

For error 3, do the same to replace RIFF and AVI with LIST and movi respectively. Be sure to put these symbols in a special file place (not in the beginning) whose shift depends on the AVI recorder. To find this shift, find the 1st video or audio block (usually identified as 00dc or 01wb), skip 12 bytes back where to put a 4-letter sequence (LIST and movi).

Case 5 is the hardest as it's a big structure where replacing 8 symbols isn't enough. So I'll describe the case where you can record another video file with the same audio and video codec settings. We'll take the needed title from it. In the new file find and copypaste all data before the LIST/movi chunk into the corrupted file.

Prior to fixing the file, first edit its reserve copy. After correction in the binary editor, process the output file in an above-mentioned AVI repair tool or the like - after your entering rough edits the software will do the rest.

© 2024 Rising Research. All rights reserved.