Sunday, September 02, 2007

Digital Video Compression Explained

Digital Video Compression Explained - Published: November 1, 2002

By Jason R. Dunn

If you use digital video, file size is an important concern because digital video files tend to take up a lot of storage space on your hard drive. The answer is compression—making files smaller.

With text files, size is less important because the files are full of “spaces” and can be compressed very tightly—a text file can be made at least 90 percent smaller, resulting in a high compression ratio (the ratio of compressed data to uncompressed data). Other file types, like MPEG video or JPEG photos, hardly compress at all because they're in a format that's tightly compressed to begin with.

Why is digital video compressed?

Digital video is compressed because it takes up a staggering amount of room in its original form. By compressing the video, you make it easier to store. Digital video can be compressed without impacting the perceived quality of the final product because it affects only the parts of the video that humans can't really detect. For example, there are billions of colors, but we perceive only about 1024 shades. Since we can't discern the subtle difference between one shade and the next we don't have to keep every color. There's also the matter of redundant images—if every frame in a 60–second video has the same chair in the same spot, why save the data of that chair in every frame?

Compressing video is essentially the process of throwing away data for things we can't perceive. Standard digital video cameras compress video at a ratio of 5 to 1, and there are formats that allow you to compress video by as much as 100 to 1. But too much compression can be a bad thing. The more you compress, the more data you throw away. Throw away too much, and the changes become noticeable. With heavy compression you can get video that's nearly unrecognizable.

When you compress video, always try several compression settings. The goal is to compress as much possible until the data loss becomes noticeable and then notch the compression back a little. That will give you the right balance between file size and quality. And remember that every video is different—some videos look great highly compressed, others don't. You'll have to experiment to get the best results.

Bit rate explained

Bit rate describes how much information there is per second in a stream of data. You might have seen audio files described as “128–Kbps MP3” or “64–Kbps WMA.” Kbps stands for “kilobytes per second,” so the higher number represents more data: 128–Kbps MP3 audio files contain twice the data as 64–Kbps WMA files and take up twice the space. (Although in this case, however, the two files would sound about the same. The reason? Some file formats use data more effectively than others, and the sound quality of a 64–Kbps WMA file is as good as the 128–Kbps MP3 file.) The important thing to understand is that the higher the bit rate, the more information, and thus the more effort it takes to decode that information, and the more space the file requires.

Selecting the proper bit rate for your projects depends on the playback target: if you're making a VCD for playback on a DVD player, the video must be exactly 1150 Kbps and the audio 224 Kbps. A typical Pocket PC running at 206 megahertz (MHz) can work with MPEG video up to 400 Kbps—anything above that will cause it to sputter during playback.

Compression strategies

There are many different approaches and strategies used to squeeze digital media files down to manageable size. Here are some of the most common ones:

Psychoacoustic audio compression

The word psychoacoustic looks complicated, but it simply means “the way the brain interprets sound.” All forms of compressed audio use powerful algorithms to discard audio information that we can't hear. As an example, if I shout at the top of my lungs and also lightly tap my foot, you'll hear my voice but you probably won't hear my foot tapping. By getting rid of that foot tapping sound, there's less information and a smaller file size, but it will sound the same to your ear.

Psychovisual video compression

Psychovisual video compression is similar to its audio counterpart. Instead of discarding audio that we can't hear, psychovisual models discard data that are eyes don't need. An uncompressed clip that shows a chair in the same location for 60 seconds repeats the same data for that chair for each frame. With psychovisual video compression, the data for that chair from a single frame is stored and reused in subsequent frames. This type of compression—called “statistical data redundancy”—is one of the mathematical tricks that WMV, MPEG, and other video formats use to compress video while retaining good quality.

Lossless compression

The term lossless means “no loss of data.” When a file is compressed in a lossless fashion, 100 percent of the data is still there, much like when you zip a document—the document file gets smaller, but all the words are still there when you unzip it. You can save lossless video over and over without any loss of data—compression simply squeezes that data into a smaller space. Lossless compression saves less space because you can compress data only so much before you have to start discarding information.

Lossy compression

Lossy compression discards data in order to achieve a lower bit rate. Psychoacoustic compression and psychovisual compression are lossy technologies that result in smaller files that contain less of the original source data. And every time you save your file in a lossy file format, it discards more of the data—even if you're saving it in the same format. A good rule of thumb is to move to a lossy format only as the very final step in your project.

Sphere: Related Content

No comments: