Embedding Video Versus Playing External Video

 < 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:

  • Only use video when appropriate. Three particular cases stand out: celebrity endorsement (that is, when the face is recognizable or important to add credibility to your message); call to action (when the video or sound can actually motivate someone to physically get up and go do what you're pushing); expert demonstrations (for example, a cook showing you how to fold eggs is something you could never really describe with pictures or words, you really need a video).

  • As far as video content is concerned, you should refrain from using many fine details, such as small text; it can become illegible in a small video window.

  • Changing viewpoints and camera angles (such as going from close up to far away) is always good. Just be aware of details that may be difficult to see on a small screen.

  • Be conservative with special effects; everything has a "price" be it lower performance, large files that download slowly, or gratuitous effects that become tiresome. Although the limits of computer videos may appear restrictive, they are really just challenges to overcome. In some ways, the restrictions of regular TV are removed. For example, you can use nearly any aspect ratio (that is, the shape wide or narrow). You can even mask the video to make any shape you want, as Figure 18.1 shows.

    Figure 18.1. Despite digital video's restrictions, you can do cool stuff such as change the viewing window's shape.


In addition to these tips, you need to consider other optimization issues, as discussed later this hour.

Supported Formats

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:

  • QuickTime (.mov)

  • Digital video (.dv)

  • MPEG (.mpg or .mpeg)

  • Windows Media (.asf or .wmv)

  • Video for Windows (.avi)

By the Way: Installing Video Support

It's possible that your system configuration won't list this many digital video formats. To increase the types of video your computer will support, install QuickTime (from www.quicktime.com). In addition, if you're using Windows, be sure to install DirectX 9 or later (www.microsoft.com/directx/). You can see which version, if any, you already have by selecting Start, Run, and then typing dxdiag and click OK.


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:

1.

To make this go quickly, I'm going to use the sample movie that came with the free version of QuickTime (which you can find at www.quicktime.com), but you can use any footage you can find. Start a new Flash movie and select File, Import, Import Video. Click the Browse button and select the file sample.mov, which is located in the QuickTime folder (that is, Program Files/QuickTime). Then click Next.

2.

The Deployment step of the video import sequence will appear as shown in Figure 18.2. Select the Embed option so that the compressed video will get saved inside the .fla and then click Next. (In fact, Flash Basic only has two options, but I'll cover all 5 options available to Flash Professional 8 after this task.)

Figure 18.2. The Deployment dialog is where you decide whether to embed or create an external .flv.


3.

The next step, Embedding, lets you select various details about how the video will appear in your file. Most of these settings are purely for convenience. For example, I recommend simply leaving the default symbol type "Embedded video" because it's simple to make the other types (Movie Clip or Graphic) by hand. For this exercise, leave the Symbol type and Audio track options as is and uncheck the two checkboxes. The only setting here that has any lasting impact is when you want to chop up your video. We'll take a quick side trip to see the video split feature so click "Edit the video first" and press Next.

4.

The Split video dialog appears as shown in Figure 18.3. This is perhaps the simplest video editor of all time. Set the in and out points (by clicking the right facing and left facing arrow buttons) and then click the plus button to add the clip. You can reorder the clips as well. I just wanted you to see this dialog but for this exercise click the Back button so that we don't trim the video. (If you happen to have only a very long video go ahead and make a short clip so the encoding process won't take all day.) Back at the Embedding dialog (first seen in step 3) change the radio button at the bottom to "Embed the entire video." Then click Next.

Figure 18.3. You can make rough edits to your video during the import process.


5.

The final screen, Encoding, lets you select the quality and corresponding bandwidth requirements from a variety of preset profiles. Only Flash Professional 8 lets you access the Advanced Settings for the On2 VP6 codec. There you can fine tune the compression settings. Select one of the Flash 7 profiles from the drop down menu and notice the details that appear underneath the menu list Sorenson Spark for the codec. This is the only codec that will work when you publish to Flash player 7. Select "Flash 8 - Low Quality (150kbps)" and you'll be taking advantage of the new On2 VP6 codec though this also means only users with the Flash Player 8 will be able to view it. The 150kpbs data rate means that the file will use 150 kilobits (not kilobytes) for every second. That is, a 10 second video will be 1500 kilobits. The idea is that if your internet connection can maintain at least 150kbps (for example, most DSL connections are approximately 256kbps) then the video can play without interruption. When you're finally ready to encode click the Next button. You'll see one more dialog reviewing what you're about to and then click Finish.

6.

You'll have to sit through the encoding process (which is, luckily, way longer than the decoding stage at the time the user watches your video). When it's done, the video you just embedded will appear in your Library. Drag the video on to your main Stage. You'll see a dialog box (see Figure 18.4) that asks if you want to extend the Timeline to accommodate the video's total number of frames (in this case, 60). Click Yes.

Figure 18.4. When you place a video on the Stage, Flash asks whether you want to extend the Timeline to accommodate the video's length.


7.

Test the movie so you can hear the audio play. (Note that the sample I used had white on the first frame, so you won't see anything if you're on Frame 1 unless your Stage is a different color.)

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 > 


    Sams Teach Yourself Macromedia Flash 8 in 24 Hours
    Sams Teach Yourself Macromedia Flash 8 in 24 Hours
    ISBN: 0672327546
    EAN: 2147483647
    Year: 2006
    Pages: 235

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net