- Using Video
- Importing Video
- Using Video
- Optimizing Video
- Other Video Options
- Summary
- Q&A
- Workshop
Optimizing Video
Two topics relate to optimization: optimizing performance and optimizing download speed. Although these are, indeed, two different topics, in the case of video, they're often related. That is, a video file with many detailed frames tends to be large (so it downloads slower), and it also tends to perform worse because there's so much data that needs to be uncompressed and displayed onscreen. The topic of playback performance is discussed in greater detail later in Hour 20. For now, let's talk about how to make video files small.
It may seem obvious that the reason to keep Flash movies small is to minimize download time. However, because Flash can stream (meaning that the movie starts playing before it's entirely downloaded), you don't need to worry so much about the entire movie's download time, rather just the pause before playback begins. For example, if a movie takes 2 minutes to download, that's only "long" if the movie's playback time is 10 seconds. Conversely, a 2-minute download for a movie that plays for 2 minutes isn't long at all considering it will start playing after only a 12-second pause (later frames are downloaded while the user watches the first frames). I calculated the preload using the following formula:
So really, the concern is keeping that preload time to a minimum. The preload time is a factor of the relationship between download time and play time (plus a 10% safety for fluctuations in connection speed). It just so happens that a video with a long playback time is nearly always going to have a similarly large download timebut not always. The point is that we care about the preload, not necessarily the total download time. By the way, the Bandwidth Profiler (introduced in Hour 20) will be instrumental for calculating actual download and preload times.
Settings for Sorenson Spark
Every time you import video into Flash you're given options as to how you want to compress the video. The compression technology used in Flash is called Spark and is licensed from Sorenson. During the process of compression, your video is analyzed for ways that similar data (say the portion of an unmoving background) can be recycled to make the file smaller. Basically, the video is compressed to make the file smaller (not unlike "zipping" or "stuffing" a file). Then after it's downloaded and playing on the user's machine, it's decompressed. In the case of zipping or stuffing a file, you want all the data in the original to be restored. That's called lossless compression. In the case of video, you want to use so-called lossy compression because it makes the file even smaller. The only side effect is that data is lost. Just like .JPG images or .MP3 sounds (which are also lossy) that's not a problem because the data that's lost is usually not noticeable. It just depends; when you compress a lot, the quality becomes notably worse.
The simple rule for compression is: compress as much as possible without compressing so much that quality becomes unacceptable. Obviously, this is subjective. And, unfortunately, video compression can be complex because multiple images as well as sound all factor into the process. Luckily, you don't have to learn any more than the few dials that appear in the Spark compression dialog box shown in Figure 17.9.
Figure 17.9 It's worth learning each setting in the compression dialog box because they affect quality and download time.
You need to make several considerations when configuring the Spark compression dialog box. Probably the first thing to note is the source video's data. The Movie Size includes the pixel dimensions (190x240 in Figure 17.9). If you want, you can scale that down by dragging the Scale slider or by typing a percentage. Any change you make will be reflected in the output properties on the right. Without exception, a scaled-down video (besides looking smaller) results in a smaller file size.
The Quality setting is the most difficult to judge because you won't see the results of a higher or lower quality until after you click OK. If you're unhappy with the quality results (either it doesn't look good or you think you could sacrifice even more quality), you'll need to re-import the video to make another selection. I suggest always setting that at least a tad lower than 100even just down to 99 will result in a smaller file without noticeable quality degradation. Actually, the best process is to go "too far" toward low quality and then back off (going higher) until you're satisfied. (Again, you'll have to re-import the video to make new compression settingsbut that's easily done from the Library item's properties dialog box shown in Figure 17.10).
Figure 17.10 To re-import (and choose different compression settings), select the properties option for the Library item.
Although Scale and Quality are subjective decisions, they happen to be the easiest to understand. Keyframe Interval requires you know a little about how Sorenson Spark compression works. It's called "temporal" (or over time), meaning that the entire first frame of the video is saved. And then, during the ensuing frames, only the difference that appears over time is saved (which saves space) until the following keyframe where the whole frame is saved again.
The Keyframe Interval lets you specify how far apart the keyframes occur. That is, exactly how many "interframes" before the next keyframe. The simple rule is a lower Keyframe Interval means more keyframes, which means a larger file but one that allows for better instant-access to any one frame. You should only select a low Keyframe Interval if you plan to script a way to play the video backward, or if the visual content is fast changing. Similarly, only select a high Keyframe Interval if the visual content is slow changing. Ultimately, you just have to play around with it and note how performance and file size are affected.
Finally, the synchronization options let you control how a video with one frame rate will play inside Flash, which has its own frame rate (which may or may not be the same). Take the likely situation in which your original video's frame rate is 30 fps, but you plan to keep your Flash movie at a more conservative 12 fps. If the video is 10 seconds long, that's a total of 300 frames. But a Flash movie at 12 fps will only display 120 frames in the same 10 seconds.
There are many options for how to deal with this mismatch. For example, you may want to import only 12 frames for every second of video; in which case, you'd only import fewer than every other frame. Or, you might want to import all 300 frames, but then the video would appear to play slowly (in addition to having audio drift out of synchand, no, you can't just play the audio slowly). You'll usually just select the option Synchronize Video to Macromedia Flash Document Frame Rate, which translates to mean: I want the video to match my current frame rate (in Flash) even if that means frames are skipped (called drop frames) during import. Realize, of course, that the motion in a 30 fps video playing at 12 fps (and having dropped frames) will look jumpier than it will at 30 fps.
In some situations you'll want to modify the default synchronize option or even turn it off. If you're importing video originally created for television, the video's frame rate may likely be the odd number 29.97 fps. In fact, this is close enough to 30 fps, where if the audio were to drift out of sync it would take a long time to notice. However, if your Flash movie is at 30 fps and you select the synchronize option, you may see a subtle visual artifact where the graphics jitter periodically. It's definitely subtle, and I can't say that I've actually seen itbut it's a real thing.
Usually, original videos will have a higher frame rate, in which case, you'll have to decide whether to drop frames to make it match. However, it's possible that the video was created at a lower frame rate. If you select the synchronize option in this case, you'll actually add paused frames to make the video match. Normally, this is not a problem; however, it's worth considering lowering the Flash movie's frame rate (that tends to make everything smaller because there will be fewer total frames). By the way, if you don't synchronize in this case (of a video with a lower frame rate), the video will play extra fast.
Just to be complete (and to perhaps add more detail than you want), I should mention a setting called Video Frames to Flash Frames Ratio. We already considered the case of a video with a higher frame rate than Flash and how you could select the synchronize option to drop the appropriate number of frames to make it stay synchronized. But what if you want to drop even more frames to make the file smaller? Naturally, the motion in the video will look even worsebut it may be worth it. The drop-down list normally shows 1:1, meaning that one video frame will be compressed for every one frame in Flash. If you set it to 1:2 that means only one video frame will be compressed for every two frames in Flash. This forces every other frame that would have otherwise been compressed to be dropped.
You can select other ratios, and each one means that the video will be jumpier but smaller. I understood this option much better when I explored different options and simply looked at the resulting output properties on the dialog box. Finally, realize that this ratio option can be independent of the synchronize. Think of it this way: Synchronize has priority, meaning that necessary adjustments are made for this first. Then, if you select a ratio other than 1:1, Flash looks at the frames it planned on compressing and then compresses even fewer depending on your setting.
Here's a quick rundown of my compression suggestions:
Select the scale (or, really, the final window size) first.
Determine the target file size (based on how much of a pause the viewer will endure).
Determine the Flash movie's frame rate before importing a video because this affects the synchronization options.
Think about the nature of your content. Does image quality or motion smoothness have a higher priority? Tinker with both the quality setting and the video-to-Flash frames ratio (to drop frames).
Always lower the quality a littleeven if just to 99.
Don't mess with the keyframe interval unless the user needs quick random access to any specific frame (in which case, you lower the keyframe interval).