PDA

View Full Version : How to manually calculate bitrate for x264/MKV


Sasovics
24th April 2008, 04:09
Hey folks,

I'd like to write my own bitrate calculator so I started to search what is the correct formula for such a calculation. I found some
and especially the one from http://www.videohelp.com/calc.htm caught my attention

Manually calculate the bitrate
The basic bitrate formula is

(Size - (Audio x Length )) / Length = Video bitrate

L = Lenght of the whole movie in seconds
S = Size you like to use in KB (note 700 MB x 1024° = 716 800 KB)
A = Audio bitrate in KB/s (note 224 kbit/s = 224 / 8° = 28 KB/s)
V = Video bitrate in KB/s, to get kbit/s multiply with 8°.

°8 bit = 1 byte.
°1024 = 1 kilo in the computer world.

Example
90 minutes video, L = 90 x 60 = 5 400 seconds
700 MB CD but be sure that if fits use a bit lower like 695 MB, S = 695 x 1024 = 711 680 KB
Audio bitrate, A = 224 kbit/s / 8 = 28 KB/s

(711 680 - (5400 x 28) ) / 5400 = 104 KB/s x 8° = 830 kbit/s.

However, using the above formula gives me always less bitrate as
the one embeded in MeGUI.

As an example let's take movie Alien vs Predator - Requiem.

Movie length = 6062sec
Audio stream length = 1117241KB (DTS audio at 1509kbps)
Desired file size = 4479MB

so using above formula I get the following

(4586496 - 1117241) / 6062 = 572kbyte/s = 4578kbps

however, using same inputs in MeGUI gives me 4684kbps

I'd say the one in MeGUI is correct as my files always meet the desired filesize, but I'd like to write my own standalone calc.

Anyone could help me to find the formula similar to what MeGUI uses ?

bob0r
24th April 2008, 04:51
Grab the megui source and read it :)

Sasovics
24th April 2008, 04:57
ehm ... that was the first thing I was looking for. However I could not find it anywhere on x264.nl

Selur
24th April 2008, 08:24
http://sourceforge.krugle.com/kse/codespaces/BvW0aO#2

Dark Shikari
24th April 2008, 08:49
That's because 1 kbps = 1000 bits per second, not 1024.