Recipe 18.1. Encoding Video


Problem

You want to encode video for playback on a web page (HTML document) or within a larger Flash framework or application.

Solution

Use the Flash 8 Video Encoder that ships with Flash Professional 8 to create Flash Video (FLV) files, or use a third-party Flash Video compression utility such as Sorenson Squeeze or On2 Flix.

Discussion

Regardless of which encoding application you use, the process of converting a source video file into a Flash Video file involves a similar approach, including the following steps:

  1. Choose a compression preset (or profile) that best suits the quality and data rate that you want to deliver to your audience.

  2. Adjust the settings within the profile to fine-tune the output (optional).

  3. Compress the video.

If you use the Macromedia Flash 8 Video Encoder, the profiles are split into two categories: Flash 7 and Flash 8. These profile names imply "Flash Player 7" and "Flash Player 8," respectively. The Flash 7 profiles use the Sorenson Spark codec, while the Flash 8 profiles use the new On2 VP6 codec. Refer to Table 18-1 to help you determine which codec you should use.

Table 18-1. Codec selection

Target factor

Sorenson Spark

On2 VP6

Earlier Flash Players, including Flash Player 6 or higher

Yes

No

Flash Player 8 or higher

Yes

Yes

Slower computers and processors, including Pentium III or earlier and PowerMac G3 processors

Yes

No

High image quality and more dynamic color range

No

Yes

Smaller file size for equivalent data rate

No

Yes

Shorter wait time during the encoding process

Yes

No

Frame sizes up to 640 x 480

Yes

Yes

Frame sizes beyond 640 x 480

Yes

No

Data rates up to 1 Mbps

Yes

Yes

Data rates beyond 1 Mbps

Yes

No

Streaming file for Flash Communication Server MX 1.5

Yes

No

Streaming file for Flash Media Server 2.0

Yes

Yes

Alpha channel for content masking

No

Yes


For most Flash Player 8 compatible movies, you will likely want to use the new On2 VP6 codec, because the image quality is superior to what you can achieve with the Sorenson Spark codec. To view a comparison of video content encoded with each codec, visit http://www.flashsupport.com/bonus/codec_comparison.

Another new feature supported only in the On2 VP6 codec is an alpha channel. An alpha channel is a mask (or matte) for the video display area, and enables you to layer (or composite) video content on top of other Flash content. For example, you can create an alpha channel around a clip of a person's body walking, and then layer that clip on top of a different graphical background in Flash. However, you can't create an alpha channel for FLV files using any encoding utility. For most video content, you need to use an application such as Adobe After Effects to remove (or key out) the area that will act as a mask. You must use QuickTime source video files to store alpha channel data that can be recognized by Flash Video encoding utilities. Later in this recipe, you will see how to encode a video file already containing a mask with the Flash 8 Video Encoder.

You can find royalty-free video content to practice encoding at the Prelinger Archive (http://www.archive.org/details/prelinger).


To encode a video file with the Flash 8 Video Encoder:

  1. Open the Flash 8 Video Encoder application, and click the Add button.

  2. In the Open dialog box, browse to the location where your video file exists, select the file, and click the Open button to add the file to the Source File list.

  3. To specify the encoding settings for the newly imported clip, select the file in the Source File list and click the Settings button. Using Table 18-1 as a guide, choose a Flash 7 or Flash 8 profile in the Flash Video Encoding Settings dialog box. When you've picked a profile that encodes with your preferred codec, determine which data rate matches the needs for your content and audience. I recommend starting with one of the Medium Quality profiles, as the image quality for this data rate (400 Kbps) retains adequate detail for most video content.

  4. By default, the encoder will create a new FLV file that uses the same name as the original source file, in the same location as the source file. Make sure that you have adequate file space remaining on the hard drive where your source file exists, to store the FLVs produced by the encoder application. If you want to use a different filename for the FLV, type a new name in the Output filename field in the Flash Video Encoding Settings dialog box.

  5. To fine-tune the selected profile's settings, click the Show Advanced Settings button. In the Encoding tab, you may want to change the Frame rate setting to more adequately suit the needs of your video clip. If the clip shows subject matter that moves across more than 30% of the video frame, you should use the "Same as source" setting so that frames are not thrown out during the encoding process. If the clips feature subject matter that stays within the same place of the video frame, such as a talking head, you can choose a slower frame rate, such as 24 or 15 fps, to achieve a better quality of image. You can also reduce the frame size of the video image to improve image quality per frame. Select the "Resize video" button to enter a new width and height for your video, such as 320 x 240 or 160 x 120. I recommend that you use the default value for the keyframe placement setting, Automatic, as this value enables the encoder to add keyframes whenever a significant change occurs within the video frame. Also, don't overlook the audio data rate setting. For narration or human speech, you can use values as low as 32 Kbps. For more high-fidelity soundtracks, such as music, you should use a higher data rate, such as 96 Kbps.

  6. If you need to crop the video frame or edit the in or out point of the video clip, you can select the Crop and Trim tab to perform these tasks. You can change the beginning (or in point) by dragging the leftmost triangle marker under the video preview, and you can change the ending (or out point) by dragging the rightmost triangle marker.

  7. When you are finished adjusting the settings, click OK to return to the default window of the Flash 8 Video Encoder. You can continue to add other video files, choosing and adjusting a different profile for each newly added clip. Click the Start Queue button to begin the process of encoding the files you added to the Source File list. The application displays the progress of the encoding procedure in the lower pane. When the encoding process has finished, you will find new FLVs in the same location(s) as your source clips or the location you specified.

To encode video containing an alpha channel in Flash 8 Video Encoder, complete these steps:

  1. Follow steps 1 through 6 from the preceding section, choosing a source video file that contains an alpha channel. You can download a sample QuickTime movie from http://www.person13.com/fcb. This file contains an alpha channel built in Adobe After Effects.

  2. In the Flash Video Encoding Settings dialog box, you must choose a Flash 8 profile. Because alpha channels require space within the data rate, you should use a medium or high-quality profile to retain image quality for the unmasked areas of the video clip. In the advanced settings area of the dialog box, select the "Encode alpha channel" checkbox below the "Video codec" combo box.

  3. Follow step 7 from the previous section, producing a new FLV from the source video file.

There are several additional Flash Video encoders that can compress video content with either the Sorenson Spark or On2 VP6 codec. Sorenson Squeeze, available from http://www.sorensonmedia.com, is the only encoding utility that can compress FLVs (or FLV content within SWFs) with the Sorenson Spark Pro codec. The Pro codec offers more compression options, such as image smoothing and playback scalability. Image smoothing attempts to smooth out blocky areas of low data-rate video content. (You shouldn't use image smoothing for bit rates that are 384 Kbps or higher.) The playback scalability option, when used during the encoding process, enables the playback decoder to more evenly drop frames when the FLV is played on slower computers or devices. For example, If you have a 30 fps FLV and the playback environment can only process the video stream at 15 fps, the playback experience will be much better with the playback scalability option enabled. Without this option, the decoder will drop frames and pause the video frame until the next keyframe is reached.

In addition to these two encoding options, Squeeze also enables you to specify CBR (constant bit rate) or VBR (variable bit rate) encoding for your FLV. All encoding performed by Macromedia Flash 8 Video Encoder is CBR, which means that the data rate of the resulting FLV is fixed throughout the entire file, regardless of the content within the video clip. As such, If you have two source video files that are 60 seconds long and you use the same compression settings on each clip, the two FLV files will have the same file size. However, with VBR encoding, the encoder can analyze the video content more thoroughly, usually in a two-pass scenario where the encoder examines the content without trying to compress it on the first pass, and then uses that analysis to aid in the second pass when it produces the FLV. During VBR encoding, the encoder can maximize the data rate (that is, use the entire data rate you've specified) for every frame that requires that much data, and minimize the data rate (that is, drop the data rate) for frames that don't contain as much detail. The final file size of a VBR-encoded file can vary for files of the same duration, depending on the content of that video.

Another popular Flash Video encoder is On2 Flix Pro. This application was originally created by Wildform, and can create more than just FLV files from your source video files. Flix can also generate vector-based SWF conversions of your video content, enabling you to create multitone palettes that resemble creative filters in Photoshop or After Effects. You can also control color, saturation, and hue values of any encoded content, including FLVs. Table 18-2 contains a feature comparison of the three encoders discussed in this section.

Table 18-2. Comparison of encoders

Feature

Macromedia Flash 8 Video Encoder

Sorenson Squeeze 4.2

On2 Flix Pro

Encode with Sorenson Spark Basic

Yes

Yes

Yes

Encode with Sorenson Spark Pro

No

Yes

No

Encode with On2 VP6

Yes

Yes

Yes

Encode with VBR compression

No

Yes

Yes

Video filters

No

Yes

Yes

De-interlacing

No

Yes

Yes

Alpha channel data-rate control

No

Yes

Yes

Batch processing

Yes

Yes

Yes

Compression profiles for batch jobs

No

Yes

Yes

Watch folder

No

Yes

Yes





Flash 8 Cookbook
Flash 8 Cookbook (Cookbooks (OReilly))
ISBN: 0596102402
EAN: 2147483647
Year: 2007
Pages: 336
Authors: Joey Lott

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net