21 April 2008
Adobe Flash CS3 Professional Video Studio Techniques covers techniques for creating and sharing optimal Flash video experiences over the web, including capturing and encoding video, creating and using cue points, working with transparency, and deploying and delivering optimal quality video. This article addresses some issues you may encounter during the encoding and deployment process.
You must upload the skin SWF file along with your Flash movie SWF file and support HTML documents to the web server for a site. The skin file is loaded at runtime. If you do not see the skin displayed when you test your Flash movie live, make sure the skin SWF has been uploaded to the web server.
Runtime filter effects are very processor-intensive. If you want to add a drop shadow or glow effect to a Flash video, create a MovieClip instance (or Sprite instance in ActionScript 3.0) behind the video, and add the filter effect to the MovieClip or Sprite instance. You should also enable the Use Runtime Bitmap Caching option in the Property inspector for such MovieClip instances. In ActionScript, this option is controlled with the MovieClip.cacheAsBitmap or Sprite.cacheAsBitmap property.
A few factors can affect Flash Player's ability to keep the frame rate of a video consistent during playback. First, make sure your Flash video file was encoded with an audio track, even if it's just audio of a looped silence track. The audio track is the governor for a Flash video's frame rate; without it, the FLV file may not play smoothly.
Another factor is the computer's processing speed. Slower computers such as an Apple PowerMac G3s or a Pentium II may not be able to play video files with large dimensions and fast frame rates. If you are experiencing choppy playback on slower computers, try testing a Flash video encoded with the Sorenson Spark codec. The Spark codec is much less processor-intensive than the On2 VP6 codec.
The NetStream class dispatches status codes during the initialization and playback of Flash video (FLV) files. To know when a video has reached its end, you should check for two consecutive events: NetStream.Play.Stop and NetStream.Buffer.Empty. The NetStream.Play.Stop event occurs when the video stream has finished loading into the Flash Player buffer, but the video in the buffer has not yet played. Therefore, you can track the event and wait for the NetStream.Buffer.Empty event to know when the remaining video in the buffer has played.
If you're using the FLVPlayback component, you don't have to monitor NetStream events. You can create a listener for the "complete" event (ActionScript 2.0) or Event.COMPLETE (ActionScript 3.0).
If an FLV file has been encoded with an older encoder tool (two or three years old), you may not be able to accurately detect the end of playback. Badly encoded Flash video files may not fire NetStream status events when the video has finished playing. Your best solution is to re-encode the source files with a current Flash video encoding tool.
You may have a problem with the Flash video encoding software. Sorenson Squeeze, in all versions supporting cue points, may not correctly encode cue points for source video files containing an alpha channel. I've also experienced problems with Squeeze's Auto Keyframes Enabled property with alpha channel footage requiring cue points. If you are experiencing problems with cue point events in ActionScript, you may want to try encoding the Flash video file with another encoder.
Always be mindful of your Flash video (FLV) file's bitrate. If you serve a high-quality, high-bitrate FLV file to a user with a slow Internet connection, the user will likely suffer through several long pauses while the video constantly buffers into the Flash Player and attempts playback. As soon as the buffer is exhausted, the video pauses and rebuffers.
If you're deploying the video with real-time streaming solutions such as Flash Media Server or a Flash Video Streaming Service provider, you must
pay careful attention to the viewer's available bandwidth and serve the appropriate bitrate to that viewer.
For more information about taking into account the varying network conditions that users may encounter while viewing streaming content, read David Hassoun's article, Dynamic stream switching with Flash Media Server 3.
Most Flash video encoders cannot fully process MPEG files. Most MPEG files are muxed, which means that the audio and video portions of the file are mixed into one track instead of two distinct and separate tracks. As such, most Flash video encoders can only recognize the video portion and not the audio portion.
The best way to encode a muxed MPEG file is to demux, or separate, the audio and video portions into two separate files without recompressing the data. You can use MPEG Streamclip, a free tool for demuxing MPEG files into video and audio files. Once you have an MPEG video file (usually a file with an .mpv extension) and an MPEG audio file (usually a file with an .mpa extension), you can use Sorenson Squeeze to encode the two files into an FLV file. Squeeze is one of the only Flash video encoders that can import a video file and link an audio file to the video.
The other alternative is to transcode the MPEG file to another format, such as a QuickTime MOV file or a Windows AVI file, with a lossless or near lossless codec. Then encode that video file to Flash video with your preferred encoding tool.
Typically, not being able to view the video portion of a source file indicates that your computer does not have the necessary video codec installed. You can find the video codec information in Apple QuickTime Player by opening the file and choosing Window > Show Movie Info (free QuickTime Player) or Window > Show Movie Properties (QuickTime Player Pro only).
Some QuickTime codecs are not freely available for download, nor are they included with the QuickTime Player installer. For example, the Apple HDV codec and the DVCPro HD codec for QuickTime are only available if you have purchased and installed Apple Final Cut Pro on a Mac OS X computer.
Confirm that you can access the FLV file directly in a web browser by typing the full URL to the file in the web browser. If the browser can locate and download the file, then you know that the URL is valid and should be accessible by the Flash SWF file.
If the browser can find the file but displays several lines of random text and numbers, your web server is not configured correctly to serve FLV files. To fix this problem, you need to add a MIME type header for the .flv file extension. If you do not administer your own web server, you may need to contact the technical support staff at your web hosting service to add the MIME type. For more information on this procedure, visit the Flash Video Hosting Providers section on my book's support page.
Tip: You can solve some problems with older FLV files by checking and correcting any errors with the metadata. The FLV MetaData Injector for Windows, available for free at www.buraks.com, can analyze and fix metadata. Adobe released FLVCheck, a free command-line utility for Windows that also can check FLV files for errors. FLVCheck Tool ships as part of Adobe Flash Media Development Server.
Note: Excerpted from Adobe Flash CS3 Professional Video Studio Techniques by Robert Reinhardt. Copyright © 2008. Used with permission of Pearson Education, Inc. and Adobe Press. For more information about this book, visit adobepress.com.