Easiest thing. We simply copy the video and audio streams, and MEncoder generates the index. Of course this cannot fix possible bugs in the video and/or audio streams. It also fixes files with broken interleaving, thus the -ni option won't be needed for them anymore.
Command:
mencoder -idx input.avi -ovc copy -oac copy -o output.avi
As a side-effect, the broken AVI fixer function enables MEncoder to append 2 (or more) AVI files:
Command:
cat 1.avi 2.avi > 3.avi mencoder -noidx -ovc copy -oac copy -o output.avi 3.avi
This expects 1.avi and 2.avi to use the same codecs, resolution, stream rate etc, and at least 1.avi must not be broken. You may need to fix your input AVI files first, as described above.