Digital video wouldn't be possible without methods for compressing the vast amounts of data necessary to describe sound and frame images. Video files can be compressed in a number of ways. This section looks at a variety of compression schemes and introduces the methods they use for achieving compression rates. Understanding your options can help you make better decisions for optimizing your video files.
Compression can be "lossless," which means no information is lost and the final file is identical to the original.
Most compression schemes use forms of lossy compression. Lossy compression sacrifices some data from the file to achieve much higher compression rates. Lossy compression schemes, such as MPEG, use complicated algorithms that toss out data for sound and image detail that is not discernible to the human ear or eye. The decompressed file is extremely similar in character to the original, yet is not identical. This is similar to the way JPEG handles still images.
Spatial (or intraframe) compression takes place on each individual frame of the video, compressing the pixel information as though it were a still image.
Temporal (or interframe) compression happens over a series of frames and takes advantage of areas of the image that remain unchanged from frame to frame, throwing out data for repeated pixels.
Temporal compression relies on the placement of key frames interspersed throughout the frames sequence. The key frames are used as masters against which the following frames (called delta frames) are compared. It is recommended that a key frame be placed once every second; therefore, if you have a frame rate of 15 fps, set your key frame rate once every 15 frames.
Videos without a lot of motion, such as talking head clips, take the best advantage of temporal compression. Videos with pans and other motion are compressed less efficiently.
There are a number of codecs (compression/decompression algorithms) that can be used to compress video files for the Web. Many of these codecs can be applied to several different file formats (discussed in the next section of this chapter).
Video-editing software packages often offer a long list of codecs in their compressor list options. Here we focus on just those that are relevant to video intended for web delivery.
Cinepak provides decent compression/decompression rates and is compatible with both QuickTime or AVI formats. It employs both spatial and temporal compression and a lossy compression scheme at lower quality levels. Low to medium quality settings will produce acceptable quality video. It is also well supported, so if you want your video to be viewable by the widest possible audience, choose Cinepak.
The Sorenson Video codec was designed for low-bandwidth applications and is capable of producing files with lower data rates (if you select the Limit Data Rate option) than Cinepak while maintaining excellent quality. It is the ideal codec for web delivery, with some concessions. First, because it uses complicated compression algorithms, it requires a lot of processing power and may not run smoothly on older machines. It also requires that users install QuickTime Version 3 or higher. While growing in popularity, it will be a while before it is completely risk-free.
The Indeo codec provides compression rates similar to Cinepak by the use of spatial and temporal compression, with lossy compression at low quality levels. Its drawbacks are that it does not maintain quality at data rates as low as Cinepak, and it requires high-end machines to perform at its best.
If your video clip is all computer-generated graphical imagery (i.e., not sourced from videotape), you may want to try the Animation compressor. Depending on the type of image, the Cinepak codec may work just as well (or better) for these types of files.
The MPEG codec can only be used when the final video file will be in MPEG format (it is not compatible with other file types). It uses a lossy compression scheme (although it may be lossless at high-quality settings) and spatial and temporal compression. MPEG offers the best compression possible, but MPEGs are not yet as widely supported on the Web as other video formats.
Copyright © 2002 O'Reilly & Associates. All rights reserved.