Xvid Qf

Qf (or quality factor) a.k.a. frame quality as it applies to encoded video streams is a rough measurement of video quality mathematically defined as:

$Q_f = \frac{1000 b}{v h f}$

where Qf is the quality factor, b is the bit rate (expressed in kbit/s), v is the vertical resolution of the frame, h is the horizontal resolution of the frame, and f is the frame rate (expressed in frames per second).

One need not calculate this for every video sample since there are applications out there that do this for you such as GSpot.

The real power of this formula is that one can use it to calculate the bit rate needed to produce an encode of a given Qf we want. When dealing with xvid or divx encoded files, a good rule of thumb is to keep the Qf somewhere between 0.20 and 0.28 and encoding to Qf values over 0.30 is just a waste of bits:

$b = \frac {v h f Q_f} {1000}$

As an example, consider a 640x360 video we are AbOUT to encode to xvid. Let's say the source was a DVD movie, and we know the frame rate is 23.976 (round to 24) frame per second since it was a film. Let's say we want a Qf of 0.28 for our encode. The math is therefore:

$b = \frac {640 * 360 * 24 * 0.28} {1000}$

or

$b = \frac {1548288} {1000}$

and

b = 1548

So to encode that source video to a Qf of 0.28 we'll need to allocate 1,548 kbit/s to the encode.