Accessibility

Best Practices for Encoding Video with the VP6 Codec

William Caulfield

Metro Encoding

Flash Video is rapidly changing the landscape of video on the web. Developers will need a new set of skills and knowledge relating to video editing, encoding, and delivery. This article introduces the video encoding process using the Flash 8 Video Encoder, a simple yet powerful tool for Flash developers.

In this article I will explain some of the basics of video encoding and give a step-by-step tour of the new Flash 8 Video Encoder with the On2 VP6 codec. The On2 VP6 codec enables Flash Video encoding at lower bit rates and larger frame sizes. At the end of this article, you will find a wide range of recommended settings for VP6 encoding. These settings provide a reference point for you as you create your own custom projects.

Requirements

To complete this tutorial you will need to install the following software:

Flash 8 Professional

Prerequisite Knowledge

Basic knowledge of video and Flash.

A Short History of Video on the Web

In 1998 web video was all about Real Media, which provided the best codecs combined with the best server. Within a few years, Microsoft had moved to the forefront with Windows Media. Apple was also on the move with QuickTime. For many years, these three companies had cornered the web video market. All had their pluses and minuses depending on the type of projects and client requirements. What they all had in common were modern video and audio codecs and the ability to deliver video through progressive download or streaming technologies. What they lacked was an easy way to add rich media and interactivity to the audiovisual experience. Developers were learning to use HTML plus TIME for Windows Media, SMIL for Real, and all the various technologies for QuickTime. None of them provided a perfect solution for delivering web video.

Experience with Flash Video

During the same period Flash became the web standard for motion graphics and interactivity on the web. A painless plug-in installation process made Flash Player practically ubiquitous on desktop and laptop computers. Developers used various approaches to integrate video with Flash. Many used Flash to make players for Windows Media, Real, and QuickTime. Others vectorized video to create an early version of Flash Video. Some began creating the video as vectorized Flash, later exporting the contents to video formats. The need for a fully integrated Flash Video codec soon became apparent.

The Spark codec brought integrated video to Flash. It marked a tremendous first step and was instantly accepted as a new alternative for web video. Our clients now use it to display television promos, music videos, and educational clips.

The New On2 VP6 Codec and How It Differs

Spark had its limitations at first. The limiting factor on quality in web video is the wide variance in download bandwidth among clients. The most important quality for a video codec intended for the web is encoding efficiency—the codec should be able to squeeze the most quality into the smallest possible bit rate. This is especially important when using streaming video. The new On2 VP6 codec brings Flash Video up to speed with the industry leaders in encoding efficiency so that Flash Video projects can keep the bit rate down and the quality up.

What You Should Know About Video

If you are a Flash developer but new to video, here are a few tips and pitfalls to avoid:

Converting Frame Sizes

Frame size (mentioned in the previous section) brings up a number of confusing issues. Most confusing is the concept of square and non-square pixels.

Television presents video as horizontal lines. Computers present video as a grid of pixels. Both use a 4 x 3 ratio for standard video playback. The digitized version is referred to as a "square pixel" resolution.

Video is often digitized at what's called a D1 resolution, which means 720 x 480 for NTSC and 720 x 576 for PAL. Within the world of the 4 x 3 standard, these are referred to as "non-square pixel" resolutions—NTSC pixels are wider at a ratio of 1.1:1 or 11/10, while PAL pixels are slightly taller at a ratio of about 0.915:1 or 54/59.

So why convert your video to square pixels and take the 720 x 480 frame to 320 x 240 or other legacy format? On one hand, that's the way it's always been done. But there's also no reason to use the non-square pixel dimensions if the encoded file will be played on a computer screen.

Since the early days of video, D1 has been the "legal" resolution. However, these are not the resolutions at which the vast majority of people watch video. As I mentioned earlier, television presents video at a 4 x 3 ratio screen size. When computers came along, screen resolutions did the same. Early computer monitor resolutions were 480 x 360 and 640 x 480 pixels; my current favorite is 1280 x 960.

Practically speaking, you should use the D1 resolution for videotape and DVD; use a 4 x 3 ratio for computer playback. A standard conversion from D1 to 4 x 3 would begin as follows:

  1. Capture at 720 x 480 pixels.
  2. Deinterlace or inverse-telecine the video (see the previous section).
  3. Crop eight pixels from the left and right sides (so it's 704 x 480).
  4. Resize the video to 640 x 480 pixels.

From here you may crop out further edge noise, crop out letterboxing, do further resizing, and so on. Everything from Step 4 onward is based on a 4 x 3 ratio.

There are times when I want to capture and de-interlace on the fly. In that case, the process would be as follows:

  1. Capture at 360 x 240 pixels.
  2. Crop four pixels from the left and right sides (so it's 352 x 240).
  3. Resize to the video to 320 x 240 pixels.

Once again, the target is a 4 x 3 resolution and the 360 x 240 resolution is only an intermediary step.

When you compare 720 x 480 and 640 x 480 video side by side on a computer screen, you'll see the most practical answer of all as to why you want to make the conversion: "That one looks stretched out!"

Working with the Flash 8 Video Encoder

The Flash 8 Video Encoder is installed in a separate directory as part of your Flash 8 Professional installation. This section walks you through some of its capabilities and features. After you know where and how to change the settings, check out the tables at the end. They give you some recommended settings for various types of projects.

When you launch the Flash 8 Video Encoder, you are presented with a simple interface. You can add content to the encoding queue by clicking the Add button or by dragging content to the queue window (see Figure 1). The default setting for encoding is Medium Quality 400 Kbps. If your source is 320 x 240 pixels or less, you may be ready to click the Start Queue button now. These default settings will give you good-quality VP6 video at the same frame size and frame rate as the source.

Cue window of the Flash Video Encoder

Figure 1. Cue window of the Flash Video Encoder

(+) View larger

If you need to change the settings or use more advanced settings, highlight one or more source files and click the Settings button.

Tip: If you want to encode the same source with different settings, highlight the source, click the Duplicate button, and then adjust the settings separately for each instance of the source.

Within this simple settings dialog box you can set your source to encode to any of the Flash 7 or Flash 8 presets. You can also rename the output file and adjust (or trim) the in/out points for the encoding process. If you need to adjust further, click the Show Advanced Settings button to reveal more encoding options (see Figure 2).

Advanced encoding settings

Figure 2. Advanced encoding settings

(+) View larger

The Crop and Trim tab gives you advanced options for cropping the frame as well as information on the trim settings (see Figure 3).

Crop and Trim tab

Figure 3. Crop and Trim tab

(+) View larger

Tip: To avoid any distortion when cropping video, crop according to the ratio of the source. For example, when cropping a 4 x 3 source (240 x 180, 320 x 240, and so on) crop three pixels from the height for every four pixels cropped from the width. For extremely accurate trim settings, click one of the trim tabs on the bottom of the scrubber and use the left and right keypad arrows to adjust the settings.

On the Encoding tab you can create a custom setting by making adjustments to the frame rate, keyframe interval, frame size, and the audio or video bit rate (see Figure 4).

Encoding tab

Figure 4. Encoding tab

(+) View larger

Tip: Never resize larger than the cropped frame size of the source.

Tables 1 and 2 give you a head start on adjusting the encoding settings for your projects. The most important variable is the amount of movement in the clip. Fast-moving music videos need a higher bit rate. Talking-head videos can be encoded using the lower bit rate settings. Adjust audio settings according to how important the audio is to your project. Music should be in stereo and go higher than 64 Kbps. Speech clips can be in mono and go as low as 16 Kbps.

Table 1. Recommended Flash Video Encoder Specs with VP6 Codec: High-Motion Video
High-Motion Video Total Bit Rate Video Bit Rate Audio Bit Rate Frame Size Frame Rate Video/Film Source Keyframe Interval*
Modem – Streaming** 40K 24K 16K mono 160 x 120 7.5/8 fps 8 sec.
Modem – Progressive 80K 64K 16K mono 160 x 120 7.5/8 fps 8 sec.
Small 220K 188K 32K mono 240 x 180 15/12 fps 8 sec.
Medium 400K 336K 64K mono 320 x 240 30/24 fps 8 sec.
Large 850K 754K 96K stereo 480 x 360 30/24 fps 8 sec.
X-Large 1400K 1304K 96K stereo 640 x 480 30/24 fps 8 sec.

* Start with an 8-second frame interval for all, and work down as needed.

** No real choice for 56K modem streaming. You must stay under 40K and you shouldn't take MP3 audio under 16K.

Table 2. Recommended Flash Video Encoder Specs with VP6 Codec: Low-Motion Video
Low-Motion Video Total Bit Rate Video Bit Rate Audio Bit Rate* Frame Size Frame Rate Video/Film Source Keyframe Interval
Modem – Streaming 40K 24K 16K mono 160 x 120 7.5/8 fps 8 sec.
Modem – Progressive 50K 34K 16K mono 160 x 120 7.5/8 fps 8 sec.
Small 100K 68K 32K mono 240 x 180 15/12 fps 8 sec.
Medium 180K 132K 48K mono 320 x 240 30/24 fps 8 sec.
Large 350K 286K 64K mono 480 x 360 30/24 fps 8 sec.
X-Large 600K 504K 96K stereo 640 x 480 30/24 fps 8 sec.

* Lots of room for adjustments here. For the interview I encoded, I could have used 32K audio throughout.

Where to Go from Here

Video for the web is an exciting field, and there's much more to learn about it. You may be shooting your own video or capturing from various sources. You may need to learn more about the preprocessing methods that yield a perfect encode from a raw capture. You may be ready to build your first Flash Video player.

Many of these subjects are covered in the Flash Video Developer Center, and much more information will be coming there. Start with the Flash Video Learning Guide, which introduces Flash Video and provides you with tools to develop your skills.

About the author

William Caulfield is video encoding manager at Metro Encoding in Los Angeles. His experience in video compression goes back to 1998, a lifetime in web years. After spending three years as lead video encoder for Starmedia Networks, he started Metro Encoding in 2001 to encode video exclusively for the web. Metro Encoding currently encodes video for many of the major film studios and record labels in Los Angeles.