Video with Adobe Flash CS4 Professional: Compression and Encoding Primer
Even with fast, fancy computers and digital devices, digital video requires a lot of bits and bytes—there’s no way to avoid throwing away visual and audio information. Storage is limited, and network bandwidth is even more so. Compression is here to stay, so you need to know how to achieve the best results with the tools at your disposal. In this chapter, you’ll learn how to make the right decisions when it comes time to compress digital video and audio into Flash-compatible video files.
Distinguishing Source Files and Their Differences
Chapter 2, “Capturing and Processing Video,” talked about the various video acquisition formats and their quality differences. When video is converted to, or acquired in, a digital format, a codec is used to effectively analyze the information in the video image and store that information on the digital tape, drive, or disc acquisition media. The term codec stands for compression and decompression: The source image is compressed during acquisition or capture and is later decompressed during playback.
A wide variety of video and audio codecs are available. Some codecs are used for professional video editing and output for TV broadcast, whereas other codecs are designed for low bit rates—ideal for video delivered over slower networks such as the Internet or mobile phone networks. Video files don’t contain the codec used to create them; the operating system or video-player application must have the codec installed in order to play back the video file. Luckily, since Flash Player 6, at least one video codec has been built into the player engine—the video codecs used by Flash-compatible video aren’t downloaded as separate files like they are with other video platforms or players.
Ideal source file formats
Source video files, which are stored in a way specific to a codec, are commonly saved in Apple QuickTime (MOV files) and Microsoft Video for Windows (AVI files). You can also use the MPEG specification as a file format (MPEG or MPG files), especially for High Definition Video or DVD Video files.
Apple QuickTime (MOV)
The QuickTime format, introduced by Apple in 1991, is more than just a video format. It’s an entire multimedia architecture, supporting interactive sprite elements and text tracks along with audio and video. You can even add Flash movie tracks to QuickTime files! If you use a Macintosh, most video applications, including Apple Final Cut Pro and iMovie, use the QuickTime format for video captures. QuickTime is available for both Mac and Windows; it supports a wide range of video and audio codecs. The QuickTime format is popular for acquisition and delivery—many Web sites feature embedded QuickTime movies that use low bit rate video and audio codecs.
Microsoft Video for Windows (AVI)
Introduced in 1992, Microsoft’s primary video-acquisition format is Video for Windows (AVI files). Most Windows-based applications save video captures in this format. AVI files are strictly audio/video content—you won’t likely deploy AVI files on Web sites. You can play the AVI file format with QuickTime Player on both Mac and Windows, but some codecs used for the AVI format aren’t available in QuickTime. Adobe Premiere Pro uses the AVI file format on Windows as the native capture-file format.
The MPEG file extension can be used on any video file that uses an MPEG video codec. Many MPEG video files are guised as AVI or MOV files. If you capture footage from an HDV camcorder, the source format is MPEG. Many other types of prosumer and professional video cameras, such as XDCAM and AVCHD camcorders, use MPEG as the transport container but may employ a different video codec than HDV. The MPEG format is also used for VOB files on DVD Video discs. Most MPEG filenames don’t indicate the version of the MPEG codec used by the video.
Ideal source video codecs
Now that you know the three primary source file formats, you can review the common video codecs you’ll find with high-quality video source files. These codecs are primarily acquisition video codecs and shouldn’t be used by video editors for final high-quality output files headed to a video encoder. For example, just because video material was shot on a DV camcorder does not mean you should output a DV file from your video-editing application—especially if you added other graphic elements, filter effects, or complex edits between scenes. Most acquisition video codecs are designed to capture and compress live action footage very well, but those codecs can’t compress other material (for example, title graphics, corporate logos, and so on) well at all. If possible, make sure you use a lossless video codec for export from your video-editing application.
The DV codec is used by MiniDV and DVCAM camcorders to capture digital video. The DV codec has a constant (fixed) data rate of 25 Mbps for video and 5 Mbps for audio. The audio data rate can be split over four 12-bit channels or two 16-bit channels.
The DV codec has several software versions, usually specific to each vendor. The Apple DV codec was initially one of the more popular versions used in nonlinear video editing, but many video professionals prefer the Avid DV codec to other versions. The Microsoft DV codec is used by most Windows video applications to capture DV footage.
Modern computers can play DV content without any proprietary equipment or software. Most video encoders handle DV footage well.
DVCPro, DVCPro HD, and AVC-Intra codecs
Panasonic introduced the DVCPro codec for standard-definition video in 1995. DVCPro equipment can play DV tapes, but not vice versa. A DVCPro recording uses twice as much tape as an equivalent DV recording. Although DVCPro equipment isn’t as popular as DV equipment, the newer DVCPro HD format (also called DV100) can record high-definition video at a variety of frame sizes and frame rates. DVCPro HD is considered a higher-quality HD video source than HDV sources; it can achieve data rates as fast as 100 Mbps. The most recent Panasonic video codec is the AVC-Intra codec, which utilizes the same AVC/H.264 compression technology discussed later in this chapter. Panasonic’s AVC-Intra can use either 50 or 100 Mbps video bit rates, and it captures amazing 10-bit color resolution. Most digital video cameras capture only 8-bit color resolution.
One of the reasons professional video editors prefer DVCPro HD source files over other HD formats is that the DVCPro HD codec is an intraframe codec. An intraframe codec does not use temporal compression—every frame in a DVCPro HD clip is a keyframe. You’ll learn more about these concepts later in this chapter.
Unfortunately, the DVCPro HD codec isn’t distributed with all video-editing or video player software. The easiest way to capture and edit DVCPro HD content is to use Final Cut Pro HD 5.0 (or newer) on a Mac.
One of the most confusing video codecs is the MPEG codec, mainly because there are so many varieties. The most popular in use today is the MPEG-2 codec, used by DVD Video discs, digital cable, and digital satellite broadcasts, as well as high-definition TV (HDTV) broadcasts. Many standards are evolving around the more complex MPEG-4 specification, including AVC/H.264 video.
Most MPEG video data is multiplexed, which means the video track is tightly interleaved with the audio track, making it more time-intensive (and problematic) for many video-encoding utilities. The process of separating MPEG video from a sync audio track is known as demuxing. If you’ve ever tried to reencode an MPEG file to another format and lost the audio track, it’s likely that the encoder couldn’t demux the audio track from the video track.
Many video encoders use QuickTime as the underlying video architecture to help convert source files into Flash-compatible video format. If you have MPEG-2 footage (including HDV footage), you may need the QuickTime MPEG-2 Playback component. You can buy this component from Apple’s site at http://www.apple.com/quicktime/mpeg2. The MPEG-2 codec doesn’t ship with either the standard or professional version of QuickTime Player.
If you have a DVD Video disc to encode into a Flash-compatible video format, you may need to demux the audio and video tracks of the MPEG files (stored as VOB files on DVD Video discs) before you take the footage into a video encoder. Many DVD Video discs use difficult audio codecs, such as AC3 audio encoding, which might be problematic for your video-encoding software. Several tools are available to transcode MPEG files to another video format before you bring it into a video encoder:
- MPEG Streamclip: This free QuickTime-enabled utility, created by Squared 5 (http://www.squared5.com), enables you to convert MPEG files into other video formats. As mentioned earlier, if you plan to use MPEG-2 footage with QuickTime, you need the QuickTime MPEG-2 Playback component installed on your system.
- DVDxDV: This Mac OS X trialware utility enables you convert an entire DVD Video disc to QuickTime file formats. If you need to transcode more than a short section of video from a DVD Video disc into Flash-compatible video, DVDxDV can reduce the work of splicing several MPEG2 files together. Visit the Web site at http://www.dvdxdv.com.
- Cinematize 2: This Mac OS X and Windows utility can also convert an entire DVD Video disc to QuickTime file formats. For more information, go to http://www.miraizon.com.
Motion JPEG (M-JPEG) codecs
Before the advent of the digital video cameras, many analog capture devices connected to the computer used Motion JPEG (M-JPEG) codecs to capture analog video footage. M-JPEG codecs have been available in QuickTime since version 2.5. If you have source footage in this codec, you shouldn’t have a problem converting it to video.
Many high-end professional video solutions use hardware codecs, which means that any video file using the codec must be played on a system with the hardware installed. To convert a hardware codec source file to video, you must run the video encoder on the same system or transcode the source file to an intermediate format.
Apple HD codecs
Apple has several high-quality codecs available for compressing HD source material. The latest, Apple ProRes 422, can be used to encode video from Macintosh computers running Final Cut Pro 6 (or Final Cut Studio 2) or newer. In August 2008, Apple added the Apple ProRes 422 codec to standard QuickTime installations, including Windows. You can also download a decoder utility from this location:
On the Macintosh, you can also use the Apple Intermediate codec, which can encode high-quality HD video. This codec is not as good as the Apple ProRes 422 codec, but if you don’t have Final Cut Pro, the Apple Intermediate codec is the next best codec to edit and output your HD footage.
Lossless video codecs
As much as the phrase lossless video codec might sound like a contradiction, some video codecs can compress video data without throwing away visual information. Just like ZIP file compression doesn’t lose data during compression, a lossless video codec simply stores the pixel values of the video frame without losing any information that was already present. Several lossless video codecs are on the market. Here are my preferred lossless codecs compatible with QuickTime:
- Animation: This long-time favorite codec of Adobe After Effects CS4 compositors is automatically included with all QuickTime installations on both Windows and Mac computers and offers excellent compression without loss of quality if you use the Best Quality setting during export. When I converted a sample 60-second DVCPro HD 720p clip at 29.97 fps to the same specifications with the Animation codec, the file size jumped from 545.2 MB to 3.81 GB—seven times bigger!
- BitJazz SheerVideo: This codec, available for purchase at http://www.bitjazz.com, can achieve lossless compression at a fraction of the file size needed by the Animation codec. The same sample clip referenced for the Animation codec compressed to 956.4 MB, less than twice the size of the original clip. This codec, though, requires much more processing power for both encoding and decoding the video clip. The codec is available in two versions: a free decoding codec and a licensed encoding codec.
- Uncompressed 8-bit and Uncompressed 10-bit: As their names imply, these codecs don’t actually compress the video data at all, and they produce large file sizes as a result. The 8-bit version supports standard bit depths for YUV video; each channel has 8 bits, or 256 levels. The 10-bit version supports 1,024 levels per channel. Most video that’s destined for online distribution won’t benefit from a 10-bit color channel, but if you need to edit your source video in the broadest color space, use the Uncompressed 10-bit codec. The same sample DVCPro HD clip cited earlier created file sizes of 3.1 GB and 4.18 GB with the Uncompressed 8-bit and Uncompressed 10-bit codecs, respectively.
Ideal source audio format
Just as important to the overall quality of a video clip, the audio codec(s) used during acquisition and editing can affect the final compressed output destined for playback on the Flash platform. When it comes to seeking out the best-quality source file, make sure you’re using uncompressed audio. Luckily, most high-quality video cameras record audio without any compression. This type of encoding is usually referred to as Linear Pulse Code Modulation (LPCM). Examples of digital video formats that use uncompressed audio include DV, HDCAM, XDCAM, DVCPro, DVCPro HD, and some implementations of AVCHD.
If your digital video acquisition format uses an MPEG-based or Dolby AC-3 audio codec to reduce overall bit rate and storage requirements, make sure your video-editing software is not recompressing final edited output. All post-production work should use uncompressed audio.