Accessibility

Table of Contents

Encoding Best Practices for Prerecorded Flash Video

Factors That Affect Video Encoding

Outside the physical properties of your video there are factors that affect the efficiency of the encoder and ultimately the user experience of the video playback. Two factors play a significant role in the encoding process: source quality and frame motion.

Source Quality

You determine the source quality of your video as soon as you press the recording button on your camera. Here are some basic rules for getting great source video quality and maximizing quality in your final compressed video.

Frame Motion

Frame motion is another factor to consider in your encoding formula: It is the percentage of pixel change from one frame to another. This change can result from character (or actor) events, camera effects, or post-production effects:

  • Character/actor events include someone walking past the lens, trees blowing, cars driving by, or an extreme close up of a face
  • Camera effects such as camera panning, zooming, or hand-holding will result in almost 100% pixel change from frame to frame
  • Postproduction effects such as dissolves, fades, wipes, or complex video effects will result in a high percentage of pixel changes from frame to frame

The higher percentage of frame motion within your video clip, the more information the encoder has to compress. If your clip is relatively still (such as a talking head video), there isn't much pixel change from frame to frame. The video compressor uses a method of dropping frames and then encoding a series of fully uncompressed frames. These uncompressed frames, called keyframes, are used to calculate and "rebuild" the missing frames during playback.

Figure 2 demonstrates this effect. The capture on the left shows a dissolve (high-motion) effect with a low data rate. The capture on the right shows the same effect with a much higher data rate.

Comparison of a low (100 Kbps) data-rate capture on the left, and a high (384 Kbps) data-rate capture on the right.
Comparison of a low (100 Kbps) data-rate capture on the left, and a high (384 Kbps) data-rate capture on the right.

Figure 2. Comparison of a low (100 Kbps) data-rate capture on the left and a high (384 Kbps) data-rate capture on the right

Notice the artifacts of the dissolve with a lower data rate in the image of the 100 Kbps capture. High motion will have the same result of a blocky and blurry image. Notice the higher-quality dissolve when using an increased data rate in the 384 Kbps capture on the right. The image is also much sharper and has a higher quality.

When little motion is involved, too much data rate is a waste of space. Figure 3 demonstrates this fact clearly. The capture on the left is the same 100 Kbps video. Notice the image quality is only slightly less then the image quality of the 384 Kbps capture. Compare that with the differences in Figure 2.

Low-motion, low data-rate capture (left), and low-motion, high data-rate capture (right)
Low-motion, low data-rate capture (left), and low-motion, high data-rate capture (right)

Figure 3. Low-motion, low data-rate capture (left) and low-motion, high data-rate capture (right)

In the images shown in Figure 3, notice that when there is little motion in the video frame, you can get away with a lower data rate, as demonstrated in the 100 Kbps image on the left. The image is much sharper in the higher data rate (383 Kbps) image on the right, but is it worth 284 Kbps extra?

Key Frames and the Key Frame Interval

Flash Video is encoded using a temporal method of digitizing. During the digitizing process, keyframes are used as full-frame, uncompressed images inserted into the video clip. These images are frames that the decoder uses to recreate the frames (delta frames) in between them. It's a similar concept to traditional Flash animation. Consider as an example, a Flash file with an object positioned on the stage. In the timeline, the object is repositioned at another frame. When played, the system calculates the in-between frames, called tweens or delta frames.

Typically, the Flash Video Exporter recommends a keyframe every four seconds to produce the optimal setting. The keyframe interval is the number of frames that pass before a new keyframe is created. It is calculated by multiplying the frame rate by the time interval (in seconds).

Formula:
frame rate (fps) x interval (sec.) = keyframe interval

Example:
15 fps x 4 sec. = 60

This places a keyframe every 60 frames starting at frame 1.

The greater the interval between keyframes, the harder it is for the codec to rebuild the missing frames. For example, a high-motion video clip with a large keyframe interval results in the perception of poorer quality. If your keyframe interval is too great, you run the risk of not having enough data rate to compress and transmit the data bits.

With Flash Video, keyframes are vital if your solution has a seek or scrub feature, which allows a user to advance the stream during playback. The streaming server Flash Communication Server is required to enable this feature.

Sorenson Squeeze Extra Encoding Features

Sorenson Squeeze (www.sorenson.com) has a unique feature called Automatic Key Frames that automatically generates a keyframe every time there is a major change in the video image (such as a straight cut). You can further control this feature by selecting the threshold of change for the keyframe generator (see Figure 4).

The Sorenson Squeeze automatic keyframe generator and quality settings help produce a cleaner, smoother FLV file.

Figure 4. The Sorenson Squeeze automatic keyframe generator and quality settings help produce a cleaner, smoother FLV file

One important feature of the product is the Drop Frames option. During the encoding process, if the data rate limit is in risk of being reached, this option maintains the integrity of the video stream. It will not compromise the quality by simply dropping frames. Because this may result in sporadic "jumps" in video playback, be careful when selecting the keyframe frequency.

The Minimum Quality option throttles the data rate dynamically to ensure that the quality of the video is within a threshold you set. Be careful with this option and make sure the Drop Frames option is also set. The data rate will increase beyond your preset limit and may result in a poor reception (rebuffering) by low-bandwidth users.

Encoding Methods

Two encoding methods are available for most streaming packages, including those that compress the FLV format. Constant bit rate encoding and variable bit rate encoding are two options for compressing a file within the limit of the data rate ceiling:

  • Constant bit rate (CBR) encoding persists the set data rate to your setting over the whole video clip. Use CBR only if your clip contains a similar motion level across the entire duration.
  • Variable bit rate (VBR) encoding adjusts the data rate down and to the upper limit you set, based on the data required by the compressor. VBR takes longer to encode but produces the most favorable results.

Many compression packages support a two-pass VBR. The first pass allows the compression package to analyze the video and store information about it before it starts the encoding process in the second pass. This option increases the time it takes to compress the video but yields much better results. Both the Flash Video Exporter and Sorenson Squeeze support two-pass VBR encoding.