View Full Version : Getting Mpeg2 bitrate
I have been searching this forum for queit some time now and I can't seem to find info on which bit in a mpeg2 stream I should be reading, before I can get the video bitrate...If anyone can advise me on how to do it ?
GZZ
hank315
12th June 2004, 00:10
That magic bit doesn't exist, most of the MPEG2 streams are VBR (Variable Bit Rate) encoded.
There is some information about the bit rate in the sequence header of a MPEG stream but even in the case of a Constant Bit Rate you can't rely on it.
hank
Guest
12th June 2004, 04:19
DVD2AVI and clones actually count the bits passed to the decoder in a unit of stream time (based on frame count and framerate).
I knew it was possible to get the bitrate out of every frame..I will look into it.
neuron2 I have been looking into the source code of DVD2AVIdg and I can find the place where it extracts the audio, but I can't find the place it reads the mpeg2 bitrate. Can you please be a more specific on where to find it inside the source code for dvd2avi. I will help me alot...
Thanks.
GZZ
Guest
13th June 2004, 23:56
In the functions Next_Packet() and Next_Transport_Packet(), in getbit.c, look for the variable Bitrate_Monitor. This accumulates the amount of data passed to the video elementary stream parser. Then, every 64 frames, in the function Write_Frame() in store.c, it is looked at and the bitrate calculated from it. From the frame rate you know how long 64 frames is.
ok - I will take a look at it, now I know what to look at...
it was too advanced for me. :/
so I did it another way around. so I just calculated the AVG bitrate like this
Bitrate = (VideoSize in Byte(pure video *.m2v) / ((Total Frames / Framerate) * 128))
it gives me the same AVG bitrate result as Mpeg Validator which I found on this site. HEHE
Don't know If my metode are correct, but it looks like its working...
GZZ
Guest
15th June 2004, 02:23
That's exactly what DVD2AVI is doing, but on a sliding window of 64 frames, so that you can see how the bitrate varies as the movie plays.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.