The use of video in Flash 8 has improved from earlier versions of Flash, and the number of websites using FLV has dramatically increased over the years. There are many options to make edits to video before you import video into a FLA document, or load FLV into a SWF file. There are also greater controls for video compression in Flash 8 and Flash 8 Video Encoder. Compressing video carefully is important because it controls the quality of the footage and the size of the file. Video files, even when compressed, are large in comparison with most other assets in your SWF file.
Note: Remember to provide the user with control over the media in a SWF file. For example, if you add audio to a document with video (or even a looping background sound), let the user control the sound.
Using Video in an Application
Before you import video into Flash, consider what video quality you need, what video format you want to use with the FLA file, and how you want it to download. When you import video into a FLA file (called embedded video), it increases the size of the SWF file that you publish. This video starts progressively downloading to the user’s computer whether or not they view the video.
You can also progressively download or stream the video at runtime from an external Flash Video (FLV) file on your server. When it starts downloading depends on how you structure your application.
Note: Video progressively downloads from the server like SWF files, which is not actually streaming. Even dynamically loading content has distinct advantages over keeping all your content in a single SWF file. For example, you will have smaller files and quicker loading, and the user only downloads what they want to see or use in your application.
You can display external FLV video using a component or a video object. A component makes developing applications with FLV video easy, because the video controls are pre-built, and you only need to specify a FLV file path to play the content. If you need to keep your SWF file the lowest possible size, you can display video in a Video object and create your own assets and code to control the video. You can also consider using the FLVPlayback component in Flash Professional 8, which has a much smaller file size than Media components (Flash MX Professional 2004 and later.)
Remember to give users a certain amount of control (such as the ability to stop, pause, play, and resume the video, and control volume) over the video in a SWF file.
You might need certain kinds of flexibility over your video, such as manipulating the video with animation, or syncing various parts of it with the Timeline. In these kinds of scenarios, you should embed your video in the SWF file rather than loading it using ActionScript or one of the Media components.
If you need more control over a video instance than the Video class allows, a best practice is to place video inside a movie clip instance. The video’s Timeline plays independently from a Flash Timeline, and you can best control timelines by placing the content inside a movie clip. You do not have to extend your main Timeline by many frames to accommodate for the video, which can make working with your FLA file difficult.
Exporting, Compression, and Hosting FLV Files
You can export FLV files from Flash Basic 8 and Flash Professional 8 authoring environments. After you import video into your document, it appears as a video symbol in the library. To export the video as FLV, select the video and then select Properties from the Library options menu. Click Export in the Embedded Video Properties dialog box to make your export settings.
Flash Professional 8 includes the Flash 8 Video Encoder and the FLV QuickTime Export plug-in. The QuickTime Exporter compresses video from third-party video editing software such as Apple QuickTime Pro and Adobe After Effects. You can also use Flash 8 Video Encoder, which is a stand-alone application that you can use to create FLV files. Because you have a lot of control over the export settings, the quality of the FLV file that is created using either of these tools is better than video exported directly from Flash.
When you compress video, remember the following recommendations:
- Do not recompress video. Recompressing video leads to quality degradation, such as artifacts. Try to use raw footage or the least compressed footage that is available to you.
- Make your video as short as possible. Trim the beginning and end of your video so it is as short as possible, and edit your video to remove any unnecessary content. This can be accomplished directly in Flash using the Video Import wizard.
- Adjust your compression settings. If you compress footage and it looks great, try changing your settings to reduce the file size. Test your footage, and modify it until you find the best setting possible for the video you are compressing. Remember that all video has varying attributes that affect compression and file size; each video needs its own setting for the best results.
- Limit effects and rapid movement. Limit movement as much as possible if you are concerned about file size. Any kind of movement, particularly with many colors, increases file size. For example, effects (such as cross fades, blurs, and so on) increase file size, because the video contains more information.
- Choose appropriate dimensions. If your target audience has a slow Internet connection (such as phone modems), you should make the dimensions of your video smaller, such as 160 x 120 pixels. If your visitors have fast connections, you can make your dimensions larger (for example, 320 x 240 pixels).
- Choose appropriate frames per second. Choose an appropriate number of frames per second (fps). If you target users that typically have older computer processors, you should choose a low rate of frames per second (such as 7 or 15 fps). If you target users with newer computers, you can use a higher rate of frames per second (such as 15 or 30 fps). You should always choose a frames-per-second rate that is a multiple of your original frame rate. For example, if your original frame rate was 30 fps, you should compress to 15 fps or 7.5 fps.
- Choose an appropriate number of keyframes. Video keyframes are different from keyframes in Flash. Each keyframe is a frame that draws when the video is compressed, so the more frequent your keyframes are the better quality the footage will be. More keyframes also mean a higher file size. If you choose 30, a video keyframe draws every 30 frames. If you choose 15, the quality is higher because a keyframe draws ever 15 frames and the pixels in your footage are more accurate to the original.
- Reduce noise. Noise (scattered pixels in your footage) increases file size. Try reducing noise using your video editor, to reduce the video file size. Using more solid colors in your video reduces its file size.
When you put FLV files on a server, they use the FLV MIME type
video/x-flv. If you have difficulty viewing FLV files after you upload your files, check that this MIME type is set on your server. FLV files are binary, and some applications that you build might require that the
application/octet-stream subtype is also set.
It’s possible to create an application and then run into problems once you upload it to your server.
- Check your Flash Player version. Make sure that you have the correct version of Flash Player required for your FLV and SWF files. For example, if you encoded your files using On2 codec, make sure that you have Flash Player 8 installed for the browsers you use to view your Flash content.
- Check your server. Your server needs to support the FLV mime type.
- Check security guidelines. If you load FLV files from another server, you need to make sure that you have the proper files or code in place to load from that external server.
- Check your target paths. Make sure that the target paths to your video are correct. If you use relative paths (such as
/video/water.flv), try using absolute paths (such as
http://www.helpexamples.com/flash/video/water.flv). If your application doesn’t work as a relative path, but does work as an absolute path, you then know that you need to correct the relative path.