[mpeg2] Help with Replex/DVBStream/Mplex Code

Warren Young warren at etr-usa.com
Mon Feb 25 16:47:16 CET 2008

Alexandre Vazquez wrote:
> And Finally, I need information about get the mux_rate. Some person told me 
> that the mux_rate is the (video_bitrate + audio_bitrate) but I don't have 
> this parameters from the TS.

There is no header with a simple bit rate as a number, if that's what 
you're looking for.

It's easy enough to calculate bit rate, though.  Just look for I, P, and 
B frame header markers in the stream and calculate how far apart they 
are in bytes.  Do this for several GOPs, and you will know bytes per 
frame over that section.

You also need to know how many frames per second there are.  You will 
either know it in advance because you know where the stream came from, 
or you can calculate it from the time stamps in the stream in much the 
same way as you calculate bytes per frame.

Given bytes per frame and frames per second, you know bytes per second.

If the stream is CBR, this should be pretty accurate.  If it's VBR, it's 
still the best you can do without just scanning the entire stream.

More information about the mpeg2 mailing list