Manifest Technology
        Making Sense of Digital Media Technology
        By Douglas Dixon
  BLOG
  ARTICLES
 - PC Video
 - Web Media
 - DVD & CD
 - Portable Media
 - Digital
     Imaging
 - Wireless
     Media
 - Home Media
 - Technology
     & Society
  GALLERIES
 - Video - DVD
 - Portable
  TECHNICAL
     RESOURCES
  ABOUT
 - What's New
<<< HOME 

 

  PC VIDEO ARTICLES

  Manifest Technology Blog -- Site: | Articles | Galleries | Resources | DVI Tech | About | Site Map |
    Articles: | PC Video | Web Media | DVD & CD | Portable Media | Digital Imaging | Wireless Media | Home Media | Tech & Society |
    PC Video: | PC Video Articles | Video Software Gallery | Video Editing Resources |

AVI Video File Formats:
    Resolution, Pixels, Colors and Compression (5/1999)

    by Douglas Dixon

Video on PC's is cool - you can download video files off the Web, and you capture clips on your home PC to share with friends. There's a standard audio / video file format under Windows called AVI (Audio Video Interleave), and Windows 9x comes with the built-in ability to play these AVI files right on your system.

But too often, when you double-click the file to play it - blam - you get a dreaded error message that Windows can't play the file. So, what's going on here? The file is good, Windows even recognizes it's an official AVI video file when you double-click it, but it still won't play!

err_explorer_cant_play.gif (5782 bytes)
Windows Explorer error dialog displayed when
you try to play an AVI file with an unknown video format.

It's Just Packaging

The sad story is that an "AVI" file is just a wrapper, a package that contains some audio / visual stuff, but with no guarantees about what's inside. Microsoft created the AVI format for packaging A/V data, but it's just a specification for sticking A/V data in a file, along with some control information about what's inside. It's sort of like having rules for putting boxes together ("insert flap A in slot B"), and rules for labeling the box, but anybody can put any sort of stuff in a box, in any language. You can make sense of the contents of a box only if you have the right translation kit, otherwise it's all Greek to you (and to Windows).

Each developer of a new A/V format is responsible for writing the translation kits that permit your Windows system to understand that flavor of AVI. These kits are called "codecs", for compressor-decompressor, because the video and audio formats usually perform some form of compression to reduce the amount of data in the file. Windows comes with some basic codecs built-in (and with additional ones in more recent versions). If you buy video capture hardware like a USB camera or a PCI board, it will include the codecs needed to understand the formats produced by the hardware. If you buy a video editing program, it will often include additional codecs to support a wider variety of video formats. However, this means you now have a license to create files that other people can't play. Unless they have the same codec, the file is useless to them.

The result is that sharing video files on PC's can be quite messy. Sometimes the hardware or software product provides a way to share codecs with others, or has posted them on a Web site. Sometimes you can find a third party that provides a compatible codec. And sometimes you can't, and it seems like nobody has considered the possibility that you might want to share your video with others. There is no central clearinghouse for video formats, no standard way to figure out how to get an AVI file to play on your system.

The same basic idea of a general file format with add-in codecs for different video formats is used for the Apple QuickTime video format. As usual, the situation is not as anarchistic on the Macintosh, because Apple tries to build in a wider range of standard formats. Things get more complicated on the PC because video files can be in both AVI (.AVI) and QuickTime (.QT) format, which means installing additional codecs for new AVI formats, plus the separate Apple QuickTime package with its own codecs.

Opening the Package

To "read the label" on an AVI file, check out its Properties dialog. In Windows 95, click on the file in the Windows Explorer and select Properties from the File menu. This brings up the Properties dialog, with three tabs: "General" for information about the file, "Details" for the video and audio data formats, and to "Preview" to play the file.

video_general.gif (10084 bytes)
The General tab of the AVI file Properties dialog displays general information about the file on disk, including its date and size.
video_preview.gif (34757 bytes)
The Preview tab provides a mini video player that lets you play through the contents of the file.

The Detail tab will tell you the bad news: If the "Video format" field says "Unknown format" then Windows does not recognize the video format and cannot play it.

video_details.gif (7433 bytes) The Detail tab displays information about the video and audio data formats in the file.

It includes the size (resolution) of each frame, the amount of data stored for each pixel (picture element) in each frame, the number of frames, the rate at which the frames are played (Frames/Sec), the data rate (KB/Sec), and the video compression format.

This short 5-sceond clip, at 320 x 240 resolution, playing at 10 frames per second, and truncated to 16 bits per pixel, still makes a 7 1/2 MB file.

Size Matters

Video makes large files. A single image file can get big by itself, but video consists of frame after frame of images, which keep piling on one after another. Big video files fill up your hard disk, clog up your system when you try to play them, get too big to copy to a friend's machine, and take much to long to transfer over the net.

To make video useful and shareable on PC's, the amount of data must be reduced to reasonable sizes. There are three basic approaches to reducing the amount of data in a video clip: reducing the resolution and length of the clip, trimming the individual pixels and color data, and compressing the frames. Each clever new approach to squeezing down the size of video data creates yet another incompatible format, and requires a new codec to play the resulting files.

Reduction

Video Format

Size (MB)

Reduce

Resolution

640x480, 30 fps, 24-bit

26.37

100%

320x240, 30 fps, 24-bit

6.59

25%

160x120, 30 fps, 24-bit

1.65

6%

Frame Rate

320x240, 15 fps, 24-bit

3.30

13%

320x240, 10 fps, 24-bit

2.20

8%

Pixel Size

320x240, 10 fps, 16-bit

1.46

6%

Color Format

320x240, 10 fps, 9-bit

0.82

3%

320x240, 10 fps, 12-bit

1.10

4%

Compression

320x240, 10 fps, JPEG 90%

0.29

1%

320x240, 10 fps, JPEG 75%

0.18

1%

Various approaches to reducing the amount of data include:
- Resolution: Dropping the frame size from 640 x 480 to 320 x 240 to 160 x 120
- Frame rate: Lowering the frame rate from 30 to 10 frames per second
- Pixel size: Trimming the pixel depth from 32 to 16 bits per pixel
- Color format: Subsampling the color to 9- or 12-bit
- Compression: JPEG compression at different ratios

Video File sizes: Chart of AVI video file sizes for a one-second video clip
file_size_chart.gif (4704 bytes)

"Full-resolution" video is typically captured at 640 x 480 resolution, 640 pixel dots across by 480 lines of pixels down. Just one frame is 900 KB of data, or almost enough to fill one floppy disk. Video clips designed to be played on a PC are typically stored at half resolution, or 320 x 240. This is a big win: the width and height are each 2X smaller, so the total amount of data is 4X smaller. For downloading and playing over the Web, video clips are typically reduced further, often down to quarter resolution, 160 x 120, or 16X smaller.

The frame rate also makes a big difference in the file size. We are used to watching video on TV displayed at 30 frames a second, and films projected in theatres at 24 frames per second. Slower rates can cause jumpiness, but are often a necessary trade-off for PC video. Lowering the frame rate to 15 or even 10 frames per second can produce a further 2X or 3X savings in the file size.

Trimming Pixels

The next step in reducing the size of a video file is to go after the image data itself, by squishing the individual pixels and stripping out some of the color. Obviously, removing information can reduce the video quality and introduce artifacts. The trick is to remove some information, without taking so much that it becomes objectionable.

Video which has not been compressed, but which may have lowered pixel sizes or color is still called "uncompressed" or "raw", and is described by the bits per pixel and the color format.

Color video data is typically captured with 24 bits of data per pixel, or 8 bits each of red, blue, and green data. A "full-color" video sequence is therefore described as "24 Bits", which provides millions of colors. The next smaller pixel size is 16 bits, or thousands of colors.

Trimming the pixel size from 24 to 16 bits gives a 1/3 reduction in the data size, but requires truncating (chopping off) some of the bits. This quantizes the range of values; instead of a subtle transition across a blue sky, you can get blotches of color with visible steps between them.

rob_24_16.jpg (14550 bytes)
Quantized 16-Bit Pixel Values:
Zoomed in to the face to see the individual pixels
with full 24-bit color (left), and truncated to 16 bits (right).
Notice the blotchy effect from the smaller range of available color values
(especially on the right side -- cheek and by the eyes).

Stripping Away Color

Another approach to reducing video file sizes is to take advantage of the fact that the eye is less sensitive to color than brightness? In order to take advantage of this, images must be represented by intensity and color, not red, green, and blue (RGB). The RGB format is great for computers and electronics (like the dots on your TV screen). However, it's not very useful for compressing images, since the brightness and color information is mixed together.

rob_orig.jpg (8630 bytes)  

Original color image of the boy by the Christmas tree. Notice the strong color in the red shirt, blue jeans, and green tree, as well as the combination of colors in the face.

The image split into its Red, Green, and Blue components.

rob_red.gif (12057 bytes) rob_green.gif (11723 bytes) rob_blue.gif (11682 bytes)

A more natural way to think about color is used in the Windows Paint color dialog, where you select color in HSL format: Hue (pure color), Saturation (clarity), and Luminance (brightness). Similarly, the YUV color format is derived from video electronics, where Y is the intensity and U and V are the color components.

color_mspaint.jpg (7054 bytes) Windows Paint, Edit Colors dialog :
Color values are displayed  in two color spaces,
- RGB (Red, Green, Blue), and
- HSL (Hue, Saturation, Luminance).
The Hues of pure color are arranged horizontally across the square like a rainbow, with Saturation ranging vertically from gray at the bottom to pure color at the top.
The Luminance or brightness range for the selected color is displayed in the thin vertical bar on the right, from black at the bottom to white at the top.

Since color is separated from brightness, it can be compressed separately. Just truncating the color bits would create blocky color patches, so instead the color can be "subsampled", reduced to lower resolution, with each color value applying to a block of pixels. When the color is smoothed out when it is expanded up for display, so neighboring pixels have slightly different colors, and avoid a blocky effect.

Intel used this approach for their YUV-9 format, where the color information is at 1/4 resolution, or one color sample for each 4 X 4 block of the original image. This provides almost a 3X size reduction; the original 24-bit image is now effectively 9 bits per pixel.

The disadvantage of subsampled color is that the color can smear, especially with highly saturated (intense) colors and at sharp edges. Intel now supports a 1/2 resolution subsampled format, YUV-12, especially for use with USB cameras. This produces a 2X reduction in the video data, with less smearing.

rob_yuv9.jpg (29288 bytes)
YUV-9 Subsampled Color:
Full-resolution Y (Brightness / intensity) image, with the U and V color components (on right) subsampled to 1/4 resolution.

Video Compression

The final step in reducing video file sizes is to use compression algorithms which operate on blocks of pixels in the image. Compression can be performed within each frame ("intra-frame"), or can be extended to take advantage of information between consecutive frames ("inter-frame").

Frame-by-frame compression is the equivalent of performing still image compression on each individual frame. This is exactly what happens with the Motion-JPEG algorithm, which just uses JPEG compression on each frame. However, frame-to-frame compression algorithms like MPEG can achieve much better video compression by encoding the difference between consecutive frames. They take advantage of similarities from one frame to another; the camera doesn’t move that far in a fraction of a second, so much of the background and even pieces of the foreground remain the same.

rob_jpeg.jpg (7079 bytes) JPEG Block Compression:

Zoomed-in view of the boy's face after severe JPEG compression, showing blocky compression artifacts.

Windows 95 comes with built-in support for the basic raw (uncompressed) video formats (8, 16, and 24-bit RGB), and includes codecs for some basic video compression algorithms, including Cinepak. More recent versions of Windows 95 and 98 also include some other codecs including MPEG-1.

Radius Cinepak is perhaps the best choice for creating a video file to be shared widely. It provides good compression with reasonable quality, and, since it is shipped with Windows, you can expect that any other system will be able to play it.

Intel also produced and freely distributes several generations of their Indeo codecs in an attempt to help jump-start PC video. These are designed for a range of typical PC uses, and are based on YUV subsampled color.

You might think that the development of international standard formats like JPEG and MPEG might have provided a consistent and reliable way to share video files on the PC. Unfortunately, things have not turned out that way. Motion JPEG (M-JPEG) is a popular format for video editing, but is typically supported only with dedicated hardware for both capture and playback. The MPEG format is just starting to become move visible on PC's. More recent versions of Windows include an MPEG-1 codec, and more video tools that support MPEG-1 are becoming available.

The Bottom Line

Unfortunately, an AVI video file is just a package of A/V stuff, with no guarantee that you can play it on any particular system. When creating video files, there is a continued conflict between the desire to have full-resolution full-rate video, and the need to lower the amount of data to a reasonable size for processing on a PC.

We've taken a tour of the different resolutions, frame rates, pixel sizes, color formats, and compression algorithms commonly used in PC video files. If you're creating a file to share with others, use a commonly-available format whenever possible, or check which formats their system supports (or be prepared to help them install a new codec). It's an unfortunately messy situation in which surprises are still too common and even standards are not standard.