Recipe 18.7. Optimizing Video PlaybackProblemYou want to ensure that the user gets the optimal video playback for his computer's bandwidth. SolutionCreate several Flash Video files (FLV), each with a specific data rate, for each piece of content. DiscussionAs 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:
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:
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.
To use SMIL data with the FLVPlayback component:
|
Tripod >> 3pod Tips & Learning and manuals for educations