Jan
30
2010
Fixing an AVI index with mencoder
This is more a “note to self”, but I’m sure others find it useful as well.
Quite often I run across AVI files with a broken index. That index is used in media players to seek rapidly in the movie file. Without an index or with a corrupt index, seeking either does not work at all or takes a long time.
mencoder, which is available on almost any platform, allows you to massage AVI files besides tons of other operations on a never-ending list of video formats.
Here’s the command to repair a broken AVI index (I used the mplayer/mencoder version that comes with the FreeBSD ports collection):
$ mencoder -idx in.avi -ovc copy -oac copy -o out.avi MEncoder 1.0rc2-4.2.1 (C) 2000-2007 MPlayer Team CPU: Intel(R) Pentium(R) 4 CPU 3.60GHz (Family: 15, Model: 4, Stepping: 10) CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1 Compiled with runtime CPU detection. success: format: 0 data: 0x0 - 0x2aea0000 AVI file format detected. [aviheader] Video stream found, -vid 0 [aviheader] Audio stream found, -aid 1 AVI: Generated index table for 332070 chunks! VIDEO: [XVID] 640x272 12bpp 23.976 fps 994.0 kbps (121.3 kbyte/s) [V] filefmt:3 fourcc:0x44495658 size:640x272 fps:23.98 ftime:=0.0417 videocodec: framecopy (640x272 12bpp fourcc=44495658) audiocodec: framecopy (format=55 chans=2 rate=48000 bits=0 B/s=17579 sample-0) Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Writing index...81f (99%) 7391.58fps Trem: 0min 690mb A-V:0.047 [993:140]] Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Video stream: 993.962 kbit/s (124245 B/s) size: 628485708 bytes 5058.428 secs Audio stream: 140.323 kbit/s (17540 B/s) size: 88735536 bytes 5058.936 secs $
You guessed it right: “in.avi” is the broken file and “out.avi” is the repaired avi-file. The whole operation took a few seconds on this 700MB file.
January 30th, 2010 at 2:06 pm
Useful, thank you
February 16th, 2010 at 6:04 am
[...] Fixing an AVI index with mencoder | kahunaburger [...]