How does avi format can store both a data stream of video and several audio streams. The exact format of these flows is not the subject of the AVI format and interpreted by an external program called codec. That is, the audio and video in AVI files can be in any format (AC3/DivX, or MP3/Xvid, among others). That’s why he is considered a container format. For all flows can be played simultaneously need to be stored in an interleaved (interleave). Thus, each file fragment has enough information to play a few frames together with the corresponding sound. Note that the AVI format supports multiple audio data streams, which in practice means that can contain multiple soundtracks in different languages. It is the media player will decide which of these flows should be played, according to user preferences. AVI files are divided into distinct pieces called chunks. Each chunk has an associated identifier called FourCC tag.The first piece is called heading and your role is to describe meta-information about the file, for example, the dimensions of the image and the frame rate per second. The second chunk contains the audio streams and video intertwined. Optionally, there may be a third chunk that acts as an index for the remaining chunks.