KingJohns Guide to bad frames
Back to table of contents

Bad frames can be the result of capturing your home movies, via a capture card, and dropping frames. When you have made your home movie, and share it with others, bad frames can also be added when that person downloads your movie.

There are several methods that can be used to deal with bad frames, the regular Virtual dub can automatically scan and mask them (See other Guide) , however when you load an AVI and you get a VBR warning (Variable Bitrate), you should use Vdub MP3 instead.

Tools
Virtual Dub MP3 Freeze

History
Long before the present vdub had the ability to search for bad frames, Vdub MP3 was released. This free program is a modified version of Vdub, which has no problems with VBR. So can be safely used for deleting parts of the AVI without worrying about VBR.

Lip Sync
Play back of the movie, may not show bad frames, most players are designed to skip though them, with perhaps only the odd frame showing artefacts. However at the same time, the player may loose audio sync when it reaches a bad frame.

Keyframes
http://www.medievaltravel.co.uk image

In the picture above, the top row represents an uncompressed AVI showing frames 1-5. As you can see each frame is a complete frame. However the next row shows the compressed Mpeg AVI with a keyframe at 1 and 5. As you can see the keyframes are showing a complete picture, but frames 2,3,4 (delta frames) are only showing what's different from the previous frame.

A keyframe is added every so many frames/seconds to keep track of the position of the movie. It also provides a good picture on which the delta frames can be based. Mpeg 1 encoding methods call keyframes Intra-frames (I-Frames). The half-frames for mpeg 1 come in two kinds, B-frames or the backward frames and P-frames the predicted frames, and are designed to only store the difference between the frames in front and the frames behind the keyframe.

Keyframes

http://www.medievaltravel.co.uk image

An AVI compressed with the popular codecs, may have keyframe spacing variation, for example DivX 3.11 alpha's default keyframe spacing is every 10 while DivX 5 is every 300.

When AVI's are made with keyframes spaced wide apart, and you try to fast forward, you may notice players struggling to lock to Keyframes.

Bad Frames

http://www.medievaltravel.co.uk image

When you download a home made movie, it can get corrupt, the original AVI may be perfect, but because of downloading errors, you could end up with a lot of bad frames. If one of the delta frames is corrupt you need to jump to the nearest keyframe before marking it for deletion.


Removing Bad Frames with Vdub MP3

Vdub MP3 will create a log file of bad frames it has found, this log file can be viewed in Windows Notepad. Those bad frames listed can then be removed easily from the AVI, starting at the highest blocks first. If you started deleting at the lowest blocks first, the frame numbers would change.

  1. Load AVI into Vdub MP3

  2. Select Video > Check video for freezes

When the scan has finished, it will either report that no bad frames have been found, or that they have been found and logged.

http://www.medievaltravel.co.uk image

Log File
Vdub MP3 creates the log file at c:\badframes.log Open the log file with notepad and view the contents. Scan though the log, and spot any jumps, insert a blank line to separate them.

A few tips might help you with this task

  1. (Control C = Copy)

  2. (Control V = Paste)

  3. (Double click text to select all)

Bad Frame Report from VirtualDub-Mp3
================================
12345
12346
12347
12348
12349
12350

Press enter to separate each block, makes it easier later...

3345667
3345668
3345669
3345670

From the above log file we can see the bad frames start at 12345 but stop at 12350 and start again at 3345667 and finally finishing at 3345670 . This shows two groups of number range, so you need to start deleting the highest number range first, if you don't, then the frame numbers will move after your first delete.


Marking the bad frames for deletion at keyframes

  1. Go to the log file and highlight the highest number of the first block 3345670

  2. Copy this number.

  3. Switch to Vdub MP3 and select from the menu Edit > Go to

  4. Paste that number into the box, and click OK

When this is done, the slide bar will jump to that frame number, at the same time you may see a report that the frame is bad. Now before you mark this you need to use the keyframe icon.
http://www.medievaltravel.co.uk image
Since this is the highest number in the list of bad frames (In the first block), you need to click the keyframe icon forward once.
http://www.medievaltravel.co.uk image
Now you can mark this as the end by clicking the black arrow at the bottom right

  1. Go back to the log file and highlight the lowest number of the first block 3345667

  2. Copy this number

  3. Switch to Vdub MP3 and select from the menu Edit > Go to

  4. Paste that number into the box, and click OK

When this is done, the slide bar will jump to that frame number, at the same time you may see a report that the frame is bad. Now before you mark this you need to use the keyframe icon.
http://www.medievaltravel.co.uk image
Since this is the lowest number in the list of bad frames (In the first block), you need to click the keyframe icon back once.
http://www.medievaltravel.co.uk image
Now you can mark this as the start by clicking the black arrow at the bottom left.

Marking the end at keyframes is much more important than marking the start at keyframes, however I think its best to mark both start and end.

You have now marked the start and end of the highest number blocks 3345667 to 3345670 you may see a small blue line at the progress bar. If there are only a few frames it may be hidden.

http://www.medievaltravel.co.uk image


Press the delete key, delete those frames

Do the same thing again with the next highest blocks (If you have more than one) in this example 12345 to 12350, and any more you may have....

When you have deleted all bad frames, you need to save out another copy using streaming

Save Out A New Copy

Video > Direct stream copy
Audio > Direct stream copy
SAVE AVI (Movie2.avi)

Saving a copy out using streaming, would be like copying a file from drive C:\ to drive D:\ and in this case missing out the bad frames.

Once the bad frames have been removed, playback problems may now be fixed, but importantly you can now use this new file with TMPGEnc to encode to some other format. Once you have removed those bad frames, you can now also use the normal vdub to save out the audio (if you wanted too) although not required, it sometimes helps people with low powered machines.