View Full Version : Looking for a simple bitrate calculator
snoofyx
10th September 2005, 13:34
Hi, is there any bitrate calculator to help me choose the right bitrate for x264 encoding ? I try to encode my dvds with 2 audio tracks, and some subtitles too, and wrap it in mp4 container to a 700MB file.
I'm looking for a simple tool, not a whole suite like meGUI, because i can't install .NET framework here. Or maybe just a method to calculate myself, with overheads and so.
I'm currently using the xvid calc, but it's not really accurate for x264 encodes.
Thanks in advance.
AlexB17
10th September 2005, 14:14
And i want it too! :) And with matroska overheads please!
Sharktooth
10th September 2005, 15:21
And i want it too! :) And with matroska overheads please!
Get the specs and do it by yourself.
snoofyx
10th September 2005, 15:31
I tried to figure out the way to calculate it myself, but didn't come with results (i tried reading some complicated tech documentation).
Could you indicate me some link to simple documentation about mp4 overheads please ?
Axed
10th September 2005, 16:18
Check the old MeGui threads, Doom9 has done some research into the MP4 overheads. I believe he stated exactly how he calculated it, but if you cant find it look at the source code.
snoofyx
10th September 2005, 16:28
ok, thank you for your help.
edit:
Right, i looked at the source code of Doom9's MeGUI:
/// <summary>
/// calculates the video bitrate given the input arguments
/// </summary>
/// <param name="audioSize">size of the audio file</param>
/// <param name="desiredOutputSize">desired size of the final MP4 file in bytes</param>
/// <param name="nbOfFrames">number of frames of the video source</param>
/// <param name="mp4Overhead">projected MP4 muxing overhead</param>
/// <param name="framerate">framerate of the video source</param>
/// <param name="isXviD">is the video xvid or not</param>
/// <param name="videoSize">the raw size of the video in kilobytes</param>
/// <returns>the video bitrate in kbit/s</returns>
public int calculateMP4VideoBitrate(long audioSize, long desiredOutputSize, int nbOfFrames,
double mp4Overhead, double framerate, bool isXviD, out int videoSize)
{
double totalOverhead = (double)nbOfFrames * mp4Overhead;
double nbOfSeconds = (double)nbOfFrames / framerate;
if (isXviD) // subtract the 24 bytes/frame AVI overhead that XviD assumes
totalOverhead -= (double)24 * (double)nbOfFrames;
long videoTargetSize = desiredOutputSize - audioSize - (long)totalOverhead;
videoSize = (int)(videoTargetSize / (long)1024);
long sizeInBits = videoTargetSize * 8;
int bitrate = (int)(sizeInBits / (nbOfSeconds * 1000));
return bitrate;
}
So i assumed the mp4Overhead at 10.4 (from this post (http://forum.doom9.org/showthread.php?p=678404#post678404))
But i'm confused it don't take in account the audio overhead... is it that audio don't have overhead in mp4 ?
Doom9
11th September 2005, 19:53
is it that audio don't have overhead in mp4 ?As it so happens, audio codecs take container overhead into account.. so if you tell your AAC encoder you want 128kbit/s, it'll give you a stream with 128kbit/s, including the container overhead. Thus, I don't have to worry about audio overhead when my audio is MP4. And if it's raw AAC, the file actually gets smaller when putting it into an MP4, but I have no numbers on how much..
10.4 bytes/frame should be reasonably accurate when using b-frames.. without b-frames I use 4.3 byte/frame.
In the same class you'll also find AVI overhead calculations (simplified, not really done by the specs), and MKV overhead calculations (also simplified.. it is impossible to calculate the mkv overhead completely accurately before video encoding, as the overhead depends on your distribution of i/p/b frames). mosu has posted the precise numbers in the container forum when I asked about mkv overhead.
I must say, being able to use a machine for your own ripping purposes (which requires the installation of at least AviSynth, plus likely an installable ripper / on-the-fly decryption layer) but not .NET surprises me a little ;) Even when we're talking about machines at work that you're not supposed to use in the first place, being able to install tools that serve only video processing, but not a generic runtime used mostly for business software, doesn't make a lot of sense to me.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.