Log in

View Full Version : avi overhead question...where is this # comming from?


morph166955
5th December 2006, 22:20
So ive been working on a little formula to estimate the avi overhead that would be in a file so that i can more accurately predict the video bitrate to use to get a target size (yea i know, LOTS of software does this already). From using google and the search on here and all that stuff I have my formula down to a very good level of estimation (im averaging ~37.5KB over my target size). While this is close, im shooting for near perfection (or atleast a little closer then what i have now)...its almost just to see if i can do it at this point since 38KB is really nothing.

The reason im doing this is because mencoder's estimation has been decently off from what im looking for (in the range of a few kb to 5-10 meg per file, which builds up enough to cause problems with dvd's). The way that my formula works is by taking specific information outputed by mencoder from the first pass, running that through the formula, and giving a bitrate to within a bit/s which is then sent too the second pass. My formula is:

( ( ( SizeRequested - AudioSizeFromMencoder ) / VideoDuration ) - ( 66 * 24 ) ) * 8 = bitrate

I generated this formula based on data from several runs on the same file with different bitrates requested. Now i know what your all saying...what is this 66*24 garbage. Well I have half of an answer, but if someone could fill me in on the second half then that would be nice. from my research, avi overhead is generated in 24byte blocks. My math has shown that i get almost exactly 66 of these blocks per second no matter what bitrate im using. My question is...what makes up the 66 blocks? i know ~24 of them are from the video frames so i must assume the other 42 are the audio, but why? I couldn't find a more in depth answer too this anywhere and the answers i found weren't really explaining anything either.

im using 24000/1001 fps, lamemp3 @ preset=128 for audio and lavc w/ options of vcodec=mpeg4:mbd=2:trell:v4mv:turbo:psnr plus the vpass/vbitrate options for the video. If anyone wants more info i can include that also but i think that should suffice for the purposes of this question. I have a feeling that the answer to my problem has to do with either the frame rate not being precisely 24 but rather 23.96, or something to do with the different video frames being used in the encode but i could be wrong on both counts with those.

Thanks all.

GodofaGap
5th December 2006, 22:51
- overhead is 24 bytes per chunk for standard, and 16 bytes per chunk for OpenDML AVI
- for video a chunk is one frame
- for CBR audio a chunk can have any length so you will have to know what your muxer is using
- for VBR audio a chunk is commonly 1 audio frame long (e.g. 1152/samplerate for MP3)
- the header can practically have any size, so again you will have to look at the muxer

morph166955
5th December 2006, 23:02
that much i understand and have gotten from my research...i was hoping for a more, mathematical approach to explain why im getting 66 as this magical # and what I can do to make my formula more accurate.

GodofaGap
5th December 2006, 23:18
If you'd understand you wouldn't be asking why you got 66. :p

The formula you really should be using is:

overhead = ([# of video chunks]+[# of audio chunks])*24 + headersize (for standard AVI)

~66 chunks per seconds sounds like you have 48kHz VBR mp3 audio as that gives 41.66 audio frames per sec.