|< Day Day Up >|
There are two general ways to play video inside Flash: either embed where you import, compress, and then place the video inside your main file or, compress the video into an .flv file and play it externally. The video file has to download in either case, but by keeping it external you can control when it downloads. Perhaps you can give the user a choice of three different videos and only download the one they select. Embedding the video not only makes your main file bigger, but the quality isn't as good as playing an external .flv. Generally, the best route is to create an .flv to play externally. However there are two cases where embedding the video is a better option. One is when the video is very short (say, less than 30 seconds) and you don't want to bother with maintaining several files (the .swf and the .flv). I say short because a long embedded video with sound will begin to drift out of synchronization. The second reason to embed video is when you need frame-by-frame control. An external .flv can only pause on keyframes (which get added automatically, but may only appear a few times per second much less frequently than every frame of video). If you want to let the user step frame-by-frame through a video clip of your golf swing, embedded video is a better choice.
Regardless of whether you plan to embed the final video or play an external .flv, you need to compress the video. That is, your source can be one of many video formats (such as MPEG or QuickTime) but it must be compressed using one of the Flash Player's two supported codecs. Namely, the older Sorenson Spark (which works in Flash Player 7 and Flash Player 6) or the newer, and much better quality, On2 VP6 codec (which requires users have Flash Player 8 or later).
Compressing a video (for embedding or to make an .flv) is only slightly more involved than importing other media types, such as sound or graphics. It really is as easy as selecting File, Import and then selecting a video. But as with sound and graphic files, there are different types of video files each with its own attributes. In addition, the tasks of making a video look good, play well, and download quickly can all require some work. The first step always is concentrating on your source video.
Making Video Look Good
We'll look at the supported video types and how to get them into Flash in a minute, but it's worth noting that the entire creation process for video involves many specialties. Even if you don't employ a Hollywood crew, you will always have the responsibilities of sound engineer, camera operator, casting agent, writer, and so on. Also, technical issues such as background noise, camera shake, and lighting all affect the final outcome. There's not enough room in this book to teach you everything about video making. Just consider learning about traditional movie making.
When you're selecting or creating videos, there are a few considerations specific to video on the computer. The entire viewing experience is much different on a computer than in your living room. The following tips come down to the fact that video on the computer has restrictions:
In addition to these tips, you need to consider other optimization issues, as discussed later this hour.
Flash can compress video in various file formats. These are all digital files saved on your computer. For example, if all you have is a videotape, you'll need to digitize it first. This involves video capture hardware, which basically records the analog video into the computer's hard disk. However, if your source video is already in a digital format (such as a mini DV video camera), making a digital copy on the computer takes little more than a cord to connect the camera to the computer (naturally, this is also a piece of hardware). Finally, although your favorite movie on DVD is in fact already saved as a digital file, you'll find it next to impossible to convert this to a digital file that Flash will import (besides the fact that you may break copyright laws to import it).
There's much more to say about the way you create high-quality digital video files on the computer. However you do it, you must create one of the following digital file formats:
Although the list of video formats is relatively long, you'll probably use only one of the first three. Although each format has its unique purpose, when it comes to importing video into Flash, you always want to start with the highest-quality source. That's because Flash always compresses the video (a little or a lot but always some). Video is like images in that quality degrades when you compress a file that's already compressed. Unfortunately, true uncompressed video files are huge. For example, the source videos I used in a recent project were about 200MB to 300MB per minute. Starting with such high quality really made a difference, even though the compressed version was less than 1MB per minute. In practice, a video that's only slightly compressed will still be high in quality but not nearly as big. Keep in mind, however, that the compression stage can be very time consuming. The On2 VP6 codec is particularly asymmetric meaning it takes longer to compress than decompress. That's usually the case with any codec, but here you could be tying up your machine for hours if not days!
Professionals creating source digital video files should have no trouble creating a QuickTime video with little or no compression (for example, the codec called "Animation"). Also, if you're copying video directly from a digital video camera, you can use one of the digital video formats (.dv). Also, many cameras will let you save a QuickTime video. Although MPEG can be high quality, there are actually several versions of it, so you'll have to test your entire process to make sure that it imports into Flash correctly. I suspect that many MPEGs you'll find have already been compressed, so you really should find a higher-quality original. The same can be said for Windows Media. I think you'll be hard-pressed to find noncompressed high-quality .asf or .wmv files. Finally, Video for Windows (.avi) files are simply not as good as QuickTime files. They're old technology. This isn't to say that you can't make a decent .avi, but just that you'll do better with QuickTime.
Don't think this section is a rule book for how you should progress. The only universal rule is that you always want to start with the highest-quality original.
Now that you have your computer set up with video support, you'll see how to import video into a Flash movie in the following task.
Try It Yourself: Embed a Video
In this task, you will embed a QuickTime video into your Flash movie. Here are the steps to follow:
If all you wanted was a video inside Flash, you could stop after the preceding task. However, like I mentioned earlier, embedding the video inside your movie the way you did in step 2 above is not always the best choice creating an external .flv is usually better. In addition to the benefits already mentioned, .flvs can also be posted on a streaming server (namely, Flash Media Server). This way, users will have hyper access to any point in the video. That is, embedding the video or playing .flvs without any special server does what is called progressive download which means users can watch the beginning of a video while the remainder downloads. The premise is that by the time the user needs to view the later portions, those frames will have finally downloaded. In the case of a true streaming server, you can jump to any point in the video and the server sends just those bits. This means users can jump ahead which is not the case in traditional progressive downloading.
I threw in this discussion of the two ways to play .flvs (progressive or streaming) because back in step 2 of the preceding task, I promised to explain the other deployment options shown in Figure 18.2. In addition to the Embedded option that you selected in the preceding task, Flash Professional 8 has two "Stream" options plus an option "Progressive download from a web server." (Plus an option for creating QuickTime which is no longer supported in Flash Player 8 so I'm not going to cover it.) Interestingly, the first three options all create the same .flv. That is, instead of embedding the video, they output a separate .flv file that loads into your movie at runtime. The only difference between these three options is how they pre-populate the parameters for the FLVPlayback component. Basically, to produce an .flv the process is nearly identical to the task above you're just outputting an .flv instead of a new item in your library. In addition, you get to select which FLVPlayback skin to use as shown in Figure 18.5. If you have Flash Professional 8 you can do exactly this in the task later this hour "Create an .flv and Use the FLVController Component."
Figure 18.5. When using Flash Professional 8 to produce an .flv you can select from a variety of skins for the FLVPlayback component.
|< Day Day Up >|