My Quick Guide: FLV vs SWF vs QT vs MPEG/WMV/AVI/Real: What Format to Use and When?

I took the liberty of compiling this quick reference guide for those of you who are new to getting video to work with your Flash projects.


FLV

FLV is a proprietary video format introduced by Macromedia in Flash MX version 6. The FLV video format uses the Sorenson Spark codec to embed video directly into a Flash project without having to link to an external source file.

However, I would not suggest using the FLV format unless you have Flash MX 2004 Pro and its MediaPlayback Component--which is an exclusive feature to the Pro version of MX 2004. This is by far the quickest and easiest means to getting slick, professional-looking video into your Flash projects. The MediaPlayback Component has a nominal set of features that are easy to implement at first glance. Customizing the MediaPlaback Component, i.e., the overall look, feel, and functionality of the component, is hardly as intuitive, even though the component can be "skinned".

You can embed a video simply by importing it onto the stage (if you are importing a QuickTime movie, select the "Embed" option). Then, use the wizard to customize the compression settings for your FLV. There are several templates available, as well as the ability to save your own custom settings for later.

Pros:
--Blazing fast performance and download speeds
--Can be used to stream or even *capture video in real time!
--Excellent quality at small file sizes

(*NOTE: The user must have a webcam installed in order to capture, and the captured video is only meant to stream live over the internet and not record to a file or cache.)

Cons:
--Not very useful without MediaPlaback Component, which is only available in the Pro version of Flash MX 2004
--Uses a proprietary codec that will only play back exclusively in the Flash Player
--Your target audience must have the very latest version of the Flash Player in order to playback FLV video

Best For:
--Streaming video (or MP3 audio) over the web
--Stand-Alone Projector files for CD presentations
--If you have an impending deadline and need a quick and easy solution


SWF

Several popular third-party video editing/compression suites can compress video directly to an SWF file. This is what prompted Macromedia and Sorenson to combine efforts on the Sorenson Spark codec and the introduction of the FLV video format.

Once you have your video in the SWF format, you can either import the SWF directly onto the stage, or load it at runtime using the MovieClip.loadMove() function. The former is NOT recommended, as it is the equivalent of iterating through a series of bitmap images, which can result in slow performance and large stand-alone SWF Projector file sizes. Instead, break your movies up into individual SWF files and load them in as-necessary at runtime using the MovieClip.loadMove() function:
Code:
myMovieClip.loadMovie("moviePath/movieName.swf" [, methods GET or POST, but usually leave blank]);
You can then code a preloader in ActionScript using the MovieClip.getBytesLoaded() and MovieClip.getBytesTotal() functions.

Pros:
--Guaranteed to play back in older versions of the Flash Player
--SWF Projector files can play back using the latest QuickTime player (which especially good for Mac users)

Cons:
--Importing SWF video directly to the stage can increase the file size of the final stand-alone SWF Projector file and slow-down its performance
--Requires nominal use of ActionScript code to load SWF video files at runtime

Best For:
--If you cannot afford to upgrade to the latest versions of Flash MX/2004/2004 Pro
--If compatibility with older projects causes an issue
--If you are not sure your target audience has the latest Flash Player installed
--To have your final SWF file reach the broadest possible target audience, including Apple QuickTime users


QuickTime (QT)

You can integrate Flash into a QuickTime movie in two steps:

Step 1: Import a QuickTime movie, and choose the "Link to external video file" option
Step 2: Publish your final Flash project as a QuickTime movie using the Publish Settings options.

When you publish your Flash project as a QuickTime movie, be sure to set the "Alpha" option to "Alpha-transparent", and the "Layer" option to "Top". This will make it so that your Flash content will overlay the QuickTime movie and mask-out all transparent layers.

If you are compiling a QuickTime movie for a CD presentation, it is usually a good idea to include the FREE QuickTime Player "Standalone Installer" somewhere on the client CD:

http://www.apple.com/quicktime/download/standalone

Pros:
--Allows you to include QuickTime users in your target audience
--Flash and QuickTime have an affinity which allows them to pass variables and events to one another programmatically

Cons
--Requires the QuickTime Player to be installed on the user's host Operating System (the very latest version recommended)
--The QuickTime Player only supports version 5 of the Flash Player format at this time: No word on when we can expect the QuickTime Player to support version 6 of the Flash Player format

Best For:
--Broadening your target audience to include Apple QuickTime users
--When the Flash browser plug-in is not available (...there's still that 2%...)


MPEG/WMV/ AVI/Real:

Before you can embed the MPEG/WMV/AVI/Real video formats into your Flash project, they will have to be compressed first into an SWF, FLV, or QuickTime movie.

Otherwise, if it is not absolutely imperative to have video featured in your Flash project, you can always use the getURL() function to link to these video file formats externally:
Code:
getURL("path/videoFile.format" [, target, methods GET or POST, but usually leave blank]);
Note that when using the getURL() function, the video file will be launched in the user's default web browser. And without messy JavaScript code, there is no way for you to ensure that your target audience has the appropriate media playback plug-in for their particular web browser.

Also, if your Flash Player is embedded in an HTML document, linking to a video file using the getURL() function will navigate the user away from the current page unless you target a "_blank" page frame; hence:
Code:
getURL("path/videoFile.format", target="_blank");
Targeting a "_blank" page frame will tell the browser to launch the video file in a separate, new window. However, without the help of JavaScript code, there is no telling where this window will appear, and what its dimensions will be.

This is a moot point regardless if you are planning to deploy a stand-alone Flash Projector file.

Pros:
--The easiest method of getting Flash to launch external video files
--Allows the user to select which video format is best suited to their needs

Cons:
--No way to know what video formats the user's host Operating System will support without clumsy, messy coding/scripting
--Doesn't do justice to your project for that polished, professional look

Best For:
--If you cannot afford to upgrade to the latest versions of Flash MX/2004/2004 Pro
--If you have an impending deadline, desperately need Flash to launch video, and have no other means is at your disposal


Perhaps if I had more time/energy/patience, I would post a side-by-side example of each of the different conventions described above.

But I don't.

Feel free to plug anything I may have missed.


Good Hunting!