Data Rates and File Sizes
It's a well-known fact that digital video usually requires large amounts of hard drive space. However, it is sometimes difficult to determine just how much space you'll need. Depending on the video format, the amount of required space can vary greatly. This purpose of this article is to explain how to calculate data rates and file sizes, hopefully eliminating any confusion on the subject.
What is a Data Rate?
Quite simply, a data rate is the rate at which information being transferred. It is expressed in terms of [amount of information] per [unit of time]. For example, a common type of data rate used when describing the speed of a hard drive is Megabytes/second. Another example would be kilobits/second, which is often used with compressed audio files. Once you determine the data rate at which your information is being transferred, it becomes possible to figure out how much hard drive space you'll need to store the video.
Bitrate-based formats are the simplest when it comes to calculating a file size. This is because a 'bitrate' is actually a data rate. Specifically, a bitrate is a data rate that is specified in terms of [number of bits] / [unit of time].
Many popular formats store data in terms of a bitrate. Some examples include DV, MPEG-1, MPEG-2, MPEG-4, RealMedia, and Windows Media. (Note: Some of these formats support variable bitrate and quality-based encoding. However, as long as you know the average bitrate, you can use it to calculate the file size.)
Calculating the File Size of a Bitrate-Based Format:
In order to calculate the file size, you'll need to know three things: the video bitrate, the audio bitrate (if your video has a soundtrack), and the length of the video. The formula is as follows:
The number of bits could be expressed in single bits, kilobits, or Megabits. You can even replace bits with bytes or seconds with another unit of time and everything will work out. All that matters is that the units for size and time are consistent throughout the equation.
Once you have the total file size (in bits, kilobits, etc.), you'll probably want to convert it to Megabytes or Gigabytes. To do so, you merely need to convert from bits to bytes and from the original prefix (kilo, etc.) to Mega or Giga. For example, here's how you would convert 36,500,000 bits to Megabytes:
1) 36,500,000 [bits] / (8) [bits/byte] = 4,562,500 bytes
2) 4,562,500 bytes / (1,048,576) [bytes/Megabyte] = ~ 4.35 Megabytes
If you need help with the conversions, see the conversion table in the Appendix.
Quality-based (or ratio-based) formats are very common in digital video capture and editing. Instead of compressing a video to a specified bitrate, they compress the video to a certain ratio of its original size. The compression ratio depends on a variety of factors, such as the video compressor, the quality of the video, and the format of the video. However, for a given video and compression codec, the ratio is relatively constant.
Some examples of quality-based codecs are Huffyuv are PICVideo MJPEG. Huffyuv is a lossless codec (it retains perfect quality), so its compression ratio isn't too high. The MJPEG codec is a lossy codec, which means that you can increase the compression ratio at the expense of some quality.
Calculating the File Size of a Quality/Ratio-Based Format:
Determining the file size of a quality-based format is a four-step process. First, you must determine the size the video would have if it had no compression. Second, you have to apply a compression ratio to the uncompressed video size to obtain the compressed video size. Third, you must calculate the size of the audio data. Forth, you simply add the audio and video sizes together. The formulas to do this are below. Let's start with figuring out the uncompressed video size:
In case you don't know, the (# bits/pixel) depends on your video's color format. For example, YUY2 and UYVY have 16 bits/pixel and RGB24 has 24 bits/pixel.
On a related note, if you run the 'AuxSetup.exe' program that comes with VirtualDub and press the Benchmark button, you will see a window that allows you to enter most of the values you see in the above formula. If you enter them, 'AuxSetup.exe' will tell you the video data rate in kilobytes/second. If you multiply this rate by the number of seconds in the video, you'll obtain the uncompressed video size (in kilobytes). This is a shortcut for people who don't like to use a calculator.
Now let's apply the video compression ratio:
As I mentioned earlier, the compression ratio depends on video codec, the quality of the video, and the format of the video. You can determine the compression ratio by creating/capturing a short clip and calculating its compression ratio. The compression ratio = (uncompressed video size / compressed video size). Also, if you capture with VirtualDub, it will show you the compression ratio in the statistics.
To help you find the compression ratio, I captured a video in Huffyuv and PICVideo MJPEG with a variety of settings. Although the ratios will be a little different for every video, my ratios should be somewhat close to the ratios you'll obtain. Therefore, if you're using Huffyuv or PICVideo MJPEG, you can use the compression ratio tables found in the Appendix to help estimate the disk space your video will take up.
Now you can determine the size of the audio data with this formula:
Windows usually shows you the audio data rate in kilobytes/second when you choose your audio format. For example, uncompressed stereo 16-bit 44.1 KHz PCM audio has a data rate of 172 kilobytes/second. Some audio formats, like MP3, refer to the data rate in terms of kilobits/second. Make sure you don't mix up bits and bytes.
Finally, you have to make sure that your video and audio sizes are in the same units (bits, kilobytes, etc.). Then you can just add them up:
Once you have the total file size (in bits, bytes, or whatever), you can convert it to Megabytes, Gigabytes, etc. as you desire. You can look at the conversion table in the Appendix if you need assistance.
Compression Ratio Tables:
|Predict left||Predict gradient||Predict median|
|Quality 16||Quality 17||Quality 18||Quality 19||Quality 20|
|Quality 16||Quality 17||Quality 18||Quality 19||Quality 20|
|8 bits = 1 byte|
|1 kilo(bit/byte) = 1,024 (bits/bytes)|
|1 Mega(bit/byte) = 1,048,576 (bits/bytes)|
|1 Giga(bit/byte) = 1,073,741,824 (bits/bytes)|