Previous Page
Next Page

Tripod >> 3pod Tips & Learning and manuals for educations

Recipe 18.7. Optimizing Video Playback

Problem

You want to ensure that the user gets the optimal video playback for his computer's bandwidth.

Solution

Create several Flash Video files (FLV), each with a specific data rate, for each piece of content.

Discussion

As discussed in the previous recipe, publishing several Flash Video files for a wide range of bit rates (or data rates) can enable you to offer your content to just about anyone watching your content. Two important factors to keep in mind with video playback over networks, including the Internet, are:


Delay

Is the user waiting too long for the video content to buffer, or does the video play nearly instantaneously?


Quality

Is the image quality of the content acceptable to the user? Is too much information lost if the image is severely compressed?

Some content can be highly compressed yet retain the information that made video the acceptable medium for communicating the content. For example, the visual of an avatar guiding you through the steps to use an online form doesn't necessarily need to be a high-quality imageas long as the audio track has sufficient quality to be intelligible by the user. Nor would such video content be conducive to user selection of the data ratethe playback of a video "guide" on a web site should be rather transparent and unobtrusive. Other content, however, may not be able to sacrifice image quality (or user choice) so easily. A movie trailer, for example, is usually watched by avid filmgoers, who appreciate detail, facial recognition of popular actors and actresses, and so on. Highly compressed audio and video information in this situation wouldn't necessarily yield satisfactory results with the target audience.

The previous recipe demonstrated how you can check the user's available bandwidth. In order to utilize that information effectively, you should compress your Flash Video content across several bit rates. By far the easiest compression utility to use for the generation of multiple data rates is Sorenson Squeeze. You can download a trial version of Sorenson Squeeze at . Follow these steps to create several FLV files for your video clip:

  1. Open Sorenson Squeeze. A new project is automatically created when you open the application.

  2. From the Format & Compression Settings pane, expand the Macromedia Flash Video (.flv) grouping. Within the grouping, you'll find several data rate-specific presets, ranging from 56 Kbps to DVD-Video quality. The Flash Video presets are divided between Flash Player 6/7 compatible formats using Sorenson Spark and Flash Player 8 formats. All Flash Player 8 formats use the VP6_ prefix in the preset name (exp 3pod.com). I recommend you use all seven Internet-ready presets, which include 56K, 112K, 256K, 384K, 512K, 768K, and 1 Mpbs, for the widest range of content distribution. Of course, you can elect to use only a few data rates depending on your server's storage capacity and bandwidth limitations. Drag each preset you wish to use to the Job pane on the right. Once you add all of the data rates you wish to use, you're ready to import clips.

    Each Sorenson Squeeze preset may use a different frame size. As such, you may want to edit each applied preset to have a consistent frame size, depending on the layout of the Flash movie that will display the video content. Otherwise, you could opt to scale all content to the largest frame size used by the highest data-rate preset. For example, if you encode a Flash Video file to 480 x 360 with the 1 Mbps_Stream preset, you could have all other data rates scale to the 480 x 360 frame size to keep a consistent layout with your Flash movie playing the content.


  3. Click the Import File button in the Input pane at the top-left corner of the application window, or choose File Import Source. Browse to one or more files that you want to encode with the selected presets. Once the files are imported, the presets in the Job pane will be copied to each content clip. You can choose to edit any of the presets individually for each clip you have added, or apply additional filters (in the Filters pane) to each clip to adjust contrast, brightness, and audio levels.

  4. Click the Squeeze It button in the lower right to begin the encoding process. Depending on the number of presets you have selected, the encoding process could take several hours to complete.

When you have encoded several data rates for your video content in Squeeze (or your preferred encoding application), you're ready to deploy a system that plays the appropriate .flv file for the user's available bandwidth. You can create your own ActionScript code that takes the user's detected bandwidth and picks the correct encoded FLV to play, or you can use the FLVPlayback component with a SMIL document.

SMIL, which stands for Synchronized Multimedia Integration Language, was developed by the W3C as a markup language to specify how text, audio, images, and video should be displayed in an interactive presentation. The most popular video player that uses SMIL is Real Systems' Real One Player, but it can also be consumed by other players such as Apple QuickTime and now Macromedia Flash Player. SMIL is just a specific schema to use with XML, and is very easy to use. You can specify the location, size, and number of data rates available for your Flash Video content, as shown in the following example:

	<smil>
	   <head>
	      <meta base="http://www.flashsupport.com/video/" />
	      <layout>
	         <root-layout width="320" height="240" />
	      </layout>
	   </head>
	   <body>
	      <switch>
	         <video src="sample_1Mbps_Stream.flv" system-bitrate="1000000" />
	         <video src="sample_768K_Stream.flv" system-bitrate="768000" />
	         <video src="sample_512K_Stream.flv" system-bitrate="512000" />
	         <video src="sample_384K_Stream.flv" system-bitrate="384000" />
	         <video src="sample_256K_Stream.flv" system-bitrate="256000" />
	         <video src="sample_112K_Stream.flv" system-bitrate="112000" />
	         <ref src="sample_56K_Dial_Up_Stream.flv" />
	      </switch>
	   </body>
	</smil>

The <head> section specifies the location of the video content, as a relative or absolute folder path on your web server (HTTP) or application URI on your Flash Communication Server/Flash Media Server (RTMP). The <body> section lists each FLV data rate, from highest bit rate to lowest. The last .flv file does not need to indicate its data rate, and will be chosen from the list as the default stream if the user's available bandwidth is lower than the second-to-last data rate listed.

If you use progressive Flash Video files (delivered from a standard web server), indicate the available bandwidth to the FLVPlayback component in ActionScript. If you serve the video content from a Flash Communication Server or Flash Media Server, you can upload the main.asc document included with Flash Professional 8's installation files to your application folder. This document has the necessary server-side handlers to communicate the available bandwidth directly to the FLVPlayback component at runtime. You can find the main.asc file in the Samples and Tutorials\Samples\Components\FLVPlayback folder.

The FLVPlayback component that shipped with Flash Professional 8 does not consume SMIL data correctly. As such, you need to reorder your content from lowest to highest, or use a corrected version of the component. You can find a fixed version of the component at .


To use SMIL data with the FLVPlayback component:

  1. Create a new Flash document in Flash Professional 8.

  2. rename Layer 1 to cfp, short for component FLVPlayback.

  3. Open the Flash document included in the fixed version download, and copy the FLVPlayback component from that document's library to your new document's stage.

  4. name (exp 3pod.com) the new instance cfp in the Property inspector.

  5. Create a new layer named actions. On frame 1 of the Actions layer, open the Actions panel. Add the bandwidth detection code presented in the last recipe. After you have determined the bandwidth, set the bit rate value of the cfp instance and then load the SMIL document. If you're playing Flash Video from a Flash Communication Server or Flash Media Server, you should not include the bandwidth detection code or specify the bit rate value.

    	cfp.bitrate = nDetectedBandwidth;
    	cfp.contentPath = sample.smil;
    

  6. Save the Flash document, and test the movie (Control/Command-Enter). When the SMIL data loads into the Flash movie, the FLVPlayback component chooses the appropriate .flv file to download, buffer, and play.

Tripod >> 3pod Botom Tips & Learning and manuals for educations

Previous Page
Next Page

 

bluedot bluedots greydots pinkdots

Tripod >> 3pod Tips & Learning and manuals for educations