Log in

View Full Version : Downloading - Difference between AVI and MPG


Appu
10th April 2007, 10:43
Hope this is the right forum to post this!..

When ever I download a file with AVI ext, I need to wait till the entire dowload finishes before I can play back the file. But this is not the case with .mpg files. Any idea why?

foxyshadis
10th April 2007, 11:40
AVI has an index at the end of the file that many programs need to play it, whereas mpg (aka mpeg program stream) is an unindexed stream.

Appu
11th April 2007, 13:15
That helps. I was under the impression that all the header info for an AVI file, is present in the beginning of a file

Turtleggjp
11th April 2007, 16:46
I once thought that too, but if you think about it, it would be very difficult to do that. The index information isn't known until the file is created, so to have it be located at the beginning of the file would mean that a temporary file would have to be created, then a new file is written starting with the index and then comes the main part of the file. It's a lot simpler to write the file first, keeping track of indexing info as you go along, and then write that info at the end when the file is finished.

Matt

unskinnyboy
11th April 2007, 17:50
That helps. I was under the impression that all the header info for an AVI file, is present in the beginning of a fileHeader is different, index is different. Don't confuse between the two. The header does occur at the beginning, and the index at the end (well, usually). The header contains information like video frame duration, number of streams, resolution of the video stream, if there is an index or not (yes, index is optional) etc. The index itself occurs at the end and could be different and of multiple types depending on what format the avi is in (1.0 Vs. Open-DML). In a nutshell, the avi index is similar to the kind of indexes you would find at the end of a book - it is a list of data chunks in the stream and the location of each chunk in the stream.

And just to cover all grounds, the index itself is optional, but highly recommended. A flag in the header says if the avi has an index or not.

foxyshadis
11th April 2007, 22:15
mkv and mp4 are front-indexed, space is reserved while muxing. TS is another unindexed stream. I have no idea about wmv and rm though.

unskinnyboy
12th April 2007, 00:34
mkv is front-indexed, space is reserved while muxing.Not entirely true. Matroska has 2 sections in the stream which comes close to an index - the Meta Seek section and the Cue section. While the Meta Seek section does contain some seeking information, it is mostly just used for storing the file information (tools reading file specs would just need to read this part). The actual seeking during playback is done with the help of Cues (consider it analogous to what a 'cue' would be in real life). And the Cues occurs in the bitstream towards the very end, just before Attachments and Tags. Meta Seek section, OTOH, occurs just after the header. Cues to Matroska is what an index is to AVI.

Appu
13th April 2007, 06:10
If the index information is present only towards the end, then how the demuxing from a real time streaming input works?. One cannot wait till end of file for streaming videos?. Buffering also doen't help here?. That is why the indexing an optional feature?. If it is optional how does the AVi Demux knows the chunk boundaries?