PDA

View Full Version : Bitrate Calculating


shevegen
29th June 2006, 23:06
Hi.
I am using mencoder to create xvid avi files. (Linux platform)

Now, lets assume I have a 1 GIG vob file. It has ac3 sound, but i dont care about it, i let mencoder convert this to mp3 (via lame)

How do I calculate the proper bitrates for a 2 pass encode?

I dont need to hit target sizes or qualities per se, I can adapt, But I think that I dont want to reach more than 1 gig .avi for a 4.3 gig move.
In fact, I think I'd be happiest around 800-950 MB for 4.3 gig start data.

I am not sure about the bitrate calculation though.

ispyhumanfly
27th July 2006, 19:37
here is a formula that i use within a perl program that i wrote to do all of my encoding for me...

# calculate the target bitrate based on the size in megabytes...
$length = 5400;
$size = 950 * 1024;
$abit = 128 / 8;
$b_rate = ( $size - ( $abit * $length ) ) / $length * 8;
( $final_rate, $b ) = split( /\./, $b_rate );
$bitrate = $final_rate;
print "a bitrate of $bitrate has been calculated...";

essentially here is the formula...

the variable $length, is the length of the film in seconds... the variable $size is the size you want in MB's * 1024, which essentially converts it into kilobytes. the variable $abit is the bitrate KB / by 8 converting it into kilobytes... and finally with that... we have size - the audio bitrate * the length of the dvd in seconds / by the length of the dvd title * 8 which brings us to the final bitrate that will get us as close as possible to our desired size.

now keep in mind... this formula is very accurate, however depending on your settings that you use you may already be forcing quite a bit of compression which might leave you with an encode that doesn't quite reach the desired out put size. typically when i shoot for let's say, 1000 megs, i'll get it in around 985mb depending on if i'm doing an x264 encode or a lavc or xvid encode.

but this formula works for me. :)