An AVI file can have an optional chunk called "idx1" which contains information about keyframes (syncpoints) and locations of video frames resp. audio chunks. Movie players use this index to seek in files.
aviindex reads the AVI file ifile and writes the index into ofile. This can either happen in "dumb" mode where aviindex looks for an existing index (and trusts this index!) in the file and dumps this index into a human readable form. The "dumb" mode is used, when -n is NOT specified or when the filesize of the input file is smaller than 2 GB.
In "smart" mode, aviindex scans through the complete AVI file and searches for chunks (may that video or audio) and reconstructs the index based on the information found. If an index chunk is found accidently, aviindex will use the information in this index to recover the keyframe information, which is important. aviindex will use smart mode, if given the -n option OR if the AVI file is larger than 2 GB. If the file is large, the index chunk cannot be found the usual way so one must use -n but it is possible that there is an index chunk in this file. Cross fingers.
Also in smart mode, aviindex analyzes the content of the video frame and tries to detect keyframes by looking at the data depending on the video codec.
The generated index file serves different purposes.
mplayer -frames 0 -saveidx mpidx broken.avi aviindex -i mpidx -o tcindex avimerge -x tcindex -i broken.avi -o fixed.aviOr the other way round
aviindex -i broken.avi -n -o broken.idx aviindex -i broken.idx -o mpidx mplayer -loadidx mpidx broken.aviThe major differences between the two index file formats is that the mplayer one is a binary format which is an exact copy of an index in the AVI file. aviindex 's format is text based. See FORMAT for details.
aviindex -i 3GBfile.avi -o 3GB.index
generates and index of the large file 3GBfile.avi. You can use the file 3GB.index to tell transcode to read the index from this file and not from the avi. This leads to much faster startup time.
Suppose 3GBfile.avi has DivX video and PCM sound and you want to encode several ranges.
transcode -V -i 3GBfile.avi --nav_seek 3GB.index \ -x xvid,avi \ -c 5000-6000,0:20:00-0:21:00,100000-100001 \ -y xvid --lame_preset standard -o out.avi
AVIIDX1 # Generated by aviindex (transcode-0.6.8) TAG TYPE CHUNK CHUNK/TYPE POS LEN KEY MS 00db 1 0 0 2048 8335 1 0.00 01wb 2 1 0 10392 847 1 0.00 01wb 2 2 1 11248 847 1 0.00 02wb 3 3 0 12104 847 1 0.00 02wb 3 4 1 12960 847 1 0.00 00db 1 5 1 13816 5263 0 0.00 00db 1 6 2 19088 3435 0 0.00 01wb 2 7 2 22532 834 1 0.00
The field TYPE is the type of the chunk. This is redundant because the type is also embedded into the TAG field but its a convenient thing to have. Its 1 for video, 2 for first audio track and 3 for second audio track.
The field CHUNK is the absolute chunk number in the AVI file. If you read the CHUNK field in the last line of the index file, you know how many chunks this AVI file has.
The field CHUNK/TYPE holds information about how many chunks of this type were previously found in the AVI file.
The field POS is the absolute byte position in the AVI file where this chunk can be found. Note this field can hold really large numbers if you are dealing with large AVIs.
The field LEN is the length of this chunk.
The field KEY holds information if this chunk is a keyframe. In the example above, all audio chunks are key-chunks, but only the first video frame is a key frame. This field is either 0 or 1.
The field MS holds information about how many milliseconds have passed. This field may be 0.00 if unknown.