From: Christophe M. <ma...@vi...> - 2001-11-06 11:00:31
|
On Tue, Nov 06, 2001, Burkhard Plaum wrote: > Now, I want to write some code, which gets the total number of audio- > and video streams contained in the file. The question is, what is the > best way to do this? Parsing the system header gives numbers, > GREATER OR EQUAL to the numbers of audio/video streams, and there > are also files, which have no system header at all (but are played > nicely e.g. > by libmpeg3). Parsing the whole stream would give exact results, but it > takes > too long and is impossible, if the input source isn't seekable. > > Is there a way to obtain the number of PES packets (or bytes), which > have to > be parsed until there was at least one PES packet from each stream? I > should > also note, that this should work for mpeg1 and mpeg2 program streams. Unfortunately, what you want to do is impossible. A new stream can begin anywhere in the file. The strategy we used in VLC is to preparse the first 5 MB of the file and add streams that begin thereafter "on the fly". But that's not what you want to do. DVDs have .ifo files for that purpose. MPEG-2 also has a structure named Program Stream Map which does exactly what you want (map all elementary streams). Unfortunately, most MPEG streams don't have this structure. I haven't found a better way in VideoLAN... -- Christophe Massiot. |