Video

Creative Commons License

Compression

Uncompressed 601 digital video has a data rate of approximately 28 Mbytes per second, or 1.7 gigabytes per minute. In order to reduce storage and bandwidth costs digital video data is usually compressed.

CODEC is short for "Compressor/Decompressor" and refers to the particular scheme used to reduce the video data. There are dozens of CODECs in common use...some require proprietary hardware to use, others are software plug ins. Some CODECs are optimized for extremely low bandwidth(i.e. streaming video) while others are designed for high image quality at correspondingly higher data rates. It is important to chose a CODEC that is appropriate for your intended use.

There are two common ways of reducing video data - Intraframe and Interframe compression. Intraframe compression looks for redundant or imperceptible data within each frame and eliminates it, but keeps each frame separate from all others. Interframe compression looks for portions of the image which don't change from frame to frame and encodes them only once. This usually involves saving a Keyframe which is a single, complete frame, and then saving a series of Delta frames which only contain the changes for each subsequent frame. All CODECs use some form of intraframe compression. More efficient CODECs generally use both intraframe and interframe compression.

Intraframe only CODECS are well suited for acquisition and post-production because they keep every frame whole and separate, making it easy to cut the video at any point. CODECs which use both are generally better suited to distribution because they allow much lower file sizes with higher picture quality.

Digital video compression is always a trade-off between file size and image quality. Lossless CODECs usually cannot reduce the data by more than half. Most CODECs attempt to reduce file size by throwing away redundant information first, then eliminating information that is least likely to be perceived by the viewer (Perceptual Encoding). The more compression you apply, the farther you push beyond the perception threshold, with the result being a noticeable reduction in image quality. Visible errors in compressed digital video are referred to as Artifacts.

Error Concatenation is the result of multiple compression passes. A CODEC cannot tell the difference between artifacts and picture detail, so artifacts tend to become more noticeable with each recompression. It is generally best to start with a high resolution, uncompressed or lightly compressed video master, and use that as a source to generate all other versions of your video (i.e. a copy for CDROM, DVD, low and high bandwidth streaming versions, etc.).

Common CODECs

Sorenson3 is the standard for CDROM and streaming video in QuickTime. It produces high quality video at relatively low data rates and scales very well (i.e. playing back a 320x240 video clip at 640x480). A basic version of it is available with QuickTime Pro, and a professional version, which gives greater control over compression parameters, is available for $600. It requires a fairly fast processor for smooth playback.

Cinepack is an older Quicktime standard and was used on most early CDROMs. While it does not produce the same quality as sorenson it plays back well on older, slower processors. It is included with QuickTime Pro.

Animation is the default codec in After Effects. It uses a form of intraframe compression called RLE - 'Run Length Encoding'. RLE simply looks for rows of pixels which are the same color, for instance, 50 blue pixels right next to each other. It can then store the pixel info once, and refer back to that info for all the other blue pixels. This results in lossless compression because it will only encode a pixel if it is exactly the same color as another one next to it; once it is decompressed you get exactly the same image you started with. It was originally designed for encoding traditional animation which is likely to contain long runs of the same color. When you use it with video or photographic data it is not very efficient, so you end up with very large file sizes. However, it still produces smaller file sizes than uncompressed, so it is popular as an interchange format between video and animation programs because it gives lossless results with a small file size decrease.

MPEG1 is an older, cross-platform standard, which was developed for VideoCDs (very uncommon in the US, but in Asia they are the equivalent of VHS VCRs here). It produces near VHS quality video at moderate data rates, but it is not used extensively anymore. It was the first published standard of the Motion Picture Experts Group, a group which was formed to agree on standards which could be used by any company to ensure compatibility in playback between different platforms. MP3, a popular audio codec you are probably familiar with, is a subset of the MPEG1 format and was originally designed to compress the audio portion of MPEG1 videos.

MPEG2 is the standard for DVD encoding. It is highly efficient, using a combination of intraframe and interframe compression plus predictive encoding (it looks at frames before and after the current one, predicts what should be in the current frame, then only encodes the differences between the predicted frame and the actual frame) and motion vectors (if a block of pixels doesn't change from frame to frame, but does change position, it saves a motion vector which describes how the block of pixels move). This allows it to maintain high quality with small file sizes. MPEG2 is very slow to encode and decode, so it typically requires hardware acceleration for both compression and playback (although modern computer processors have reached the point where they can decode MPEG2 without additional acceleration).

MPEG4 is a new, open standard which is starting to come into use. It is a highly efficient codec, and it is optimized for low to mid bandwith applications. Because it is an open standard any company can integrate MPEG4 playback into their software. This means, theoretically, that anything you author in MPEG4 should be able to play back on any computer or media software. Of course, because it's new, support is still very hit-or-miss at this point, so you can't be sure your audience will be able to view your video. However, given a little time, MPEG4's combination of efficient compression and open standards will most likely make it the best choice for delivering video over the internet in the near future.

DivX started out as a hack to provide encoding access to Microsoft's MPEG-4v3 codec (which was not a true MPEG4 codec) and has transitioned over the years into the equivalent of MP3 for video. It is now based on an open source implementation of the MPEG4 standard and provides very high quality encoding at moderately low data rates. It is the format of choice for pirated DVD content online because it allows a DVD to be compressed down to a few hundred megabytes which can be downloaded reasonably quickly on broadband. Despite it's popularity online it hasn't recieved much commercials attention and is rarely used for legal distribution of video content - although there are dvd players on the market now which support playback of DivX.

JPEG (named after the "Joint Photographic Experts Group", a standards group similar to MPEG but focused on still images) is a common codec used for still images, especially common on the internet. It can be used for video as well, and at it's highest quality setting provides a reasonable file size reduction with essentially no visible image degredation. It is often used to compress clips on stock footage CD-ROMs. However, it is not truly lossless, so if you recompress a video with JPEG several times you will begin to see artifacts. JPEG is what we will be using from this point out when you turn in videos because even at it's medium quality setting it results in very good video at a small file size.

MJPEG or "Motion JPEG" is a generic name for a type of codec which is commonly used in video capture cards. It's based on the JPEG still image codec. Your video essentially becomes a series of still images compressed with a form of JPEG. It's main advantage over standard JPEG is support for interlaced video. It has the advantage of scaling from very low to very high data rates with a corresponding range of quality choices. However, it usually requires dedicated hardware (a capture card) for capture and playback, at higher quality it produces fairly large file sizes, and it's usally tied to a particular card - i.e. MJPEG captured on a Media100 system wont play back on your Avid system without being converted first.

DV is the native compression format of MiniDV, Digital8, and DVCAM cameras. It uses 4:1:1 sampling to reduce the data rate to ~15MB/s, then uses a 5:1 intraframe compression to achieve a final data rate of 3.6MB/s. It requires acceleration (typically a chip located in the camera) for compression and full-quality playback.

For a reasonably recent comparison of some of these codecs see Extreme Tech's Video Codec Shootout

Special Considerations for Low Bandwidth Video

Video with a lot of detail will not compress efficiently. Especially when targeting very low bandwidth, you should try to eliminate detail in your video image (i.e. use a background without a lot of detail in it).

Fast motion also creates a problem for low bandwidth compression. When the camera is moving each frame is different than the one preceeding it making it difficult to do efficient interframe compression, so static shots (camera on a tripod) will compress much better than handheld shots.

Dissolves and other transitions also cause each frame to become unique and will not compress well. Straight cuts are best when editing video targeted at a low bandwidth.

Fast cuts (MTV style) also do not compress well because each cut requires a new keyframe...the more keyframes your video needs, the higher it's data rate will be.

When efficient interframe compression is not possible, the CODEC will resort to very high intraframe compression to fit video within the target data rate. This will result in a significant loss of quality and detail in your video (it usually becomes very "blocky"). If you shoot the video with the above constraints in mind you can avoid this and get fairly clean video even at very low data rates.

If you reduce the size(height/width in pixels) of your video by 50%, you reduce it's data rate by 75%. Thus you will not need as much compression to hit a target data rate and your images will look much cleaner. Reducing the frame rate will also allow for less compression; 10 frames per second is acceptable for video without a lot of motion in it and results in a file which is 1/3 the size of standard 30fps video.

Compression in After Effects

In After Effects, compression comes into play at two points in your project - the video you bring into your projects, and the video you eventually render out.

When bringin video into AE, the general rule of thumb is that you want the best possible quality to work with. This means, ideally, that you want either uncompressed or lossless compression on your source projects. However, as I've mentioned before, in digital video we are always dealing with a trade off between quality and file size. Often it won't be possible to get uncompressed video for your project because it will take up too much disc space and/or require expensive capture cards. So you always want to work with the best possible quality you can get. If you can't use uncompressed or lossless compression, your next best bet is MJPEG with a fairly high data rate. After that, it's probably DV. Below DV quality you start getting into interframe codecs like sorenson, which are really meant for small file sizes and not quality. This means you will be starting out with low quality video, and your final video is likely to be of even lower quality. Unless that is the look you are going for, stay away from anything below DV when bringing video into AE.

Output is a little more flexible, but the important thing to remember is to choose the appropriate codec for the next step in your project. If you are taking your video back into an editing program such as Final Cut Pro, you want to follow similar guidelines for importing into after effects - use the highest quality codec you can 'afford'. If you are going to the internet or a CD-ROM, choose an interframe codec which will give you a much more manageable file size.

One particular situation you should be aware of is working with DV. This format has become so popular due to it's combination of low cost and high quality that there is a good chance you will be working with it in the future if you continue working with After Effects. If you are working with DV, you want to stay with DV from start to finish. You will bring it into your editing program via firewire, export the clips you want to use in AE without recompressing them (keep them DV), then set up your comps in AE for DV. There is a "DV - NTSC" preset you can choose when creating a comp, or you can enter the following settings yourself - 720x480 pixels, 29.97 frames per second, and rectangular pixels. When you are done, you want to render out with the same settings and make sure you choose the 'DV' codec for your finished movie. Then, when you import the renderd clip back into your editing program it should play right away without any further conversion.