Home » Questions » Computers [ Ask a new question ]

How can I repair a broken AVI file?

How can I repair a broken AVI file?

I have an .avi file that is about 110mb. When I try to play it with VLC Media Player it says something like "This file is broken. Attempt to repair?" and after it does its thing it is still unable to play it.

Asked by: Guest | Views: 256
Total answers/comments: 4
bert [Entry]

"I've had some luck in the past with a lot of broken/incomplete AVIs using DivFix, but not sure if it works well on anything later than Windows XP.

A newer version is DivFix++:

DivXFix++ is designed to repair broken AVI file streams by rebuilding index part of file. This is very useful when trying to preview movies which has no index part, like some files are currently downloading from ed2k or bittorent networks. DivFix++ is complete rewrite of ""DivFix"" program due it's bugs and low performance."
bert [Entry]

VirtualDub can do pretty amazing things with broken AVI files. Just open the file in VirtualDub, let it cook, and then if it's opened it successfully, re-save it as a new AVI file. Usually, you don't even need to change the compression settings.
bert [Entry]

"All good ideas for how to repair the broken AVI index (my preference is ffmpeg), but contributing here a way to find avi files that have the broken index to test them and proactively repair them. After unsuccessfully trying to use mediainfo ffprobe and others to detect files that vlc would complain about, I finally decided to use vlc since it was the one that's complaining. Here's a snippet that may be useful as part of a scan and automated repair script.

if grep -q ""avi demux error"" \
<(cvlc --vout null --aout null --stop-time 2 ""${VIDFILE}"" vlc://quit 2>&1 )
# alternate ways to stop after two seconds
#<(timeout 2 cvlc --vout null --aout null ""${VIDFILE}"" 2>&1)
#<(cvlc --vout null --aout null ""${VIDFILE}"" 2>&1 & sleep 2; kill $!)
then
echo ""avi demux error: ${VIDFILE}""
exit 1
fi

Note: the alternate stopping methods (so it doesn't play the whole video before exiting) are included because some versions of VLC have a bug in --stop-time and other systems may not have timeout."
bert [Entry]

"I've had good experience so far with Media Player Classic and The KMPlayer. They can play files which have been partially downloaded, or broken into parts (by hjsplit for example).

I think they may be able to play yours.

Although, it also depends on the type of codec and so ..."