Bitrates and File Size: the relationship

Discuss about generic usage of MediaCoder.

Moderator: HuggiL

Locked
meRobs
Expert
Expert
Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

Bitrates and File Size: the relationship

Post by meRobs » Wed Jan 09, 2013 4:47 pm

[Updated:]

Users quite often wonder about the size of a video file and what effect the video bitrate, for example, has on the size. Hence, I figure this Guide might come in handy.

Section 1: introduction
In the SI system of measurement, large numbers are expressed either in scientific notation, such as, 7x10^9 for 7 billion, or by using 1000 as a multiplier. Thus, we have prefixes of ‘kilo’ to mean 1000, ‘mega’ for 1,000,000 and ‘giga’, which is 1000 times larger again (1000^3 or 10^9).

However, computer ‘people’ like to talk in binary when dealing with data. The basic unit is a ‘bit’ and the next step up is a ‘byte’, which is 8 bits (2^3 bits). In that case, a similar multiplier for expressing large numbers would be 1024, which is 2^10. And, to avoid confusion, we need different prefixes. The equivalent to a GB is the GiB (Gibibyte) for 1024^3 = 1024x1024x1024 = 1,048,576 bytes. Notice that “GiBi” stands for Giga-binary and, similarly, KiB would be kilo-binary (= 1024 bytes).

Unfortunately, the world is confusing, and the computer industry prefers to keep it that way. So, in Windows Explorer, a kB is 1024 bytes, a MB is 1024x1024 bytes and a GB is 1024x1024x1024 bytes. More correctly, the units should have been KiB, MiB and GiB.

A standard DVD (DVD-5), when originally defined, had a capacity of 5 (actual) GB, which became 4.70 GB after some parameters had been tidied up. In binary, this is 4.3772 GiB and, to be consistent with the computer usage, it would be 4.38 GB, when rounded to only 2 decimal places. This doesn’t look as good as 4.7 when you are selling something, so they revert to the correct terminology and state it as 4.7 GB.

Section 2: calculation
So, keeping in mind this confusing state of affairs, let’s calculate the size of a media file and relate it to the video and audio streams. The first thing to realise is that the size of a media file is dictated only by the size of its data streams (video, audio and subtitles) and its header, which contains info on the contents. To simplify the calculation, I shall ignore the subtitles, which are small and often not present, and the size of the header, which is even smaller.

Secondly, the size of the video or audio stream is represented by its bitrate, which is expressed in “kbps” (kilobits per second) and sometimes in Mbps (Mega …). So, if the bitrates are V kbps for the video and A kbps for the audio, and both have a duration of T seconds, they consume (V+A)T kilobits. This now needs to be converted to kB, MB or GB.

Since, there are 8 bits in a byte, we need to divide by 8 and, since we need to express the size in computer-talk, which ambiguously uses kB to mean 1024 bytes, we need to divide by 1.024 as well. So, the total size of the two streams is S, where
...... S = (V+A) x T / (8x1.024)
........ = (V+A) x T / 8.192 .......... kB ........................... eqn (1)
..... or = (V+A) x T / 8388.61 ...... MB

For example, with video at 1000 kbps and audio at 128 kbps, a 1 hour movie (T = 60x60 sec) would have a file size of:
...... S = (1000+128) x 60x60 /8.192 = 495,703 kB
..... or = 495,703 / 1024 = 484.1 MB

On the other hand, if you wish to calculate the video bitrate for a given output file size S in MB, assuming an audio rate of A kbps:
...... V = 8388.6 x S / T – A ...... kbps, with S in MB (T in sec)
..... or = 139.8 x S / T – A ....... kbps, with T in minutes ....... eqn (2)
Have you checked out the Tips & Guides for MediaCoder? Try: http://forum.mediacoderhq.com/viewtopic.php?f=17&t=8061
Also, get older builds at: http://www.videohelp.com/tools/MediaCoder/old-versions#download

meRobs
Expert
Expert
Posts: 3116
Joined: Tue Jun 23, 2009 2:45 pm
Location: Sydney, Australia

Re: Bitrates and File Size: the relationship

Post by meRobs » Wed Jan 09, 2013 5:18 pm

The above post has been added to Tips & Guides.

If any users could make any suggestions or add useful comments, please start a new Topic that refers to this one or, if you wish to remain anonymous, send a Private Message (click on my username, top left).
Thanks
Have you checked out the Tips & Guides for MediaCoder? Try: http://forum.mediacoderhq.com/viewtopic.php?f=17&t=8061
Also, get older builds at: http://www.videohelp.com/tools/MediaCoder/old-versions#download

Locked