[Ffmpeg-devel] mpeg2 in libavcodec - mux multiple video streams into one mpeg2 stream

leon z leonleon77
Thu Aug 3 12:10:51 CEST 2006

Hi all,

a rather simple question in relation to using libavcodec to encode (and 
eventually decode) multiple video programs in a single mpeg2 stream.

>From my understanding of mpeg2 - it allows for mulitplexing of multiple 
video streams into a single data stream (e.g. frames from multiple cameras 
are encoded into multiple packatised elementary streams [pes] which are then 
multiplexed at the encoding stage into either a transport or a program 

the api example in libavcodec shows nicely the encoding (and subsequent 
decoding) of video frames, but not in a case of multiplexing frames from 
multiple video sources/streams (e.g. how would one select which video stream 
to decode when decoding mpeg2 stream and how would one denote which video 
stream should be associated with a given frame when encoding, etc.) ... my 
understaing is that it is important to have multiplexing at packet level (as 
multiplexing at frame level will result in a too big latency if there are 
say 24 video streams being encoded - the last stream will be about 1 sec. 
late...) so the notion of just encoding one frame at a time for various 
video streams and then multiplexing those is not too cool...

may be I am missing something here... but first question is:

does libavcodec support multiplexing multiple video streams in a single 
mpeg2 data stream?

if so - a quick pointer to example or open source program which uses this 

if not - any other altenative open source lib which would be able to do so?

Kind regards

Win petrol with drive.com.au ? 3 times each weekday!  

More information about the ffmpeg-devel mailing list