AVI File Format
AVI (short for audio video interleaved) is a type of riff (short for resource Interchange File Format) file format. It is used for audio and video capturing, editing, and playback.Program. Normally, an AVI file can contain multiple different types of media streams (in typical cases, there is an audio stream and a video stream ), however, AVI files containing a single audio stream or a single video stream are also valid. Avi is the most basic and commonly used media file format in windows.
First, we will introduce the riff file format. The riff file uses the four-character code fourcc (four-character code) to characterize the data type, such as 'riff', 'av', and 'LIST. Note: In Windows, the byte sequence is little-Endian. Therefore, the actual DWORD Value of a four-character code 'abcd' should be 0x64636261. In addition, it is legal that the four-digit code contains spaces like 'av.
The riff file first contains a file header structure.
The first four bytes are a four-byte code 'riff', which indicates that this is a riff file, followed by four bytes to indicate the size of the riff file; then there is a four-digit code indicating the specific type of the file (such as avi and wave), and finally the actual data. Note that the calculation method of the file size value is: actual Data Length + 4 (size of the file type field); that is, the file size value does not include the size of the 'riff' and "file size" fields.
In the actual data of the riff file, the list and chunk are usually used for organization. The list can be nested with sublists and blocks. Here, the list structure is: 'LIST' listsize listtype listdata -- 'LIST' is a four-byte code, indicating that this is a list; listsize occupies 4 bytes and records the size of the entire list; listtype is also a four-digit code, indicating the specific type of the List; listdata is the actual list data. Note that the listsize value is calculated as follows: the actual length of the list data + 4 (the size of the listtype field); that is, the listsize value does not include the size of the 'LIST' and listsize fields. Next, let's look at the block structure: ckid cksize ckdata -- ckid is a four-byte code that represents the block type. cksize occupies 4 bytes and records the size of the entire block. ckdata is the actual block data. Note that the cksize value refers to the actual block data length, excluding the size of the ckid and cksize fields. (Note: In the following content, a list is represented in the form of list (listtype (listdata), and a block is represented in ckid (ckdata, for example, the elements in [optional element] are represented as optional .)
Next we will introduce the AVI file format. The AVI file type is represented by a four-character code 'avi. The structure of the entire AVI file is: a riff header + two lists (one for describing the media stream format, one for saving media stream data) + an optional index block. The structure of the AVI file is roughly as follows:
Riff ('av'
List ('hdrl'
'Avih '(Master Avi information header data)
List ('strl'
'Strh' (Stream header information data)
'Strf' (Stream format information data)
['Strd' (optional additional header information data)]
['Strn' (name of an optional stream)]
...
)
...
)
List ('movi'
{Subchunk | list ('rec'
Subchunk1
Subchunk2
...
)
...
}
...
)
['Idx1' (optional Avi index block data)]
)
This article is transferred from
Http://www.ieee.org.cn/dispbbs.asp? Boardid = 61 & id = 47093