Digital Web Magazine

The web professional's online magazine of choice.

The Rise of Flash Video, Part 3

Got something to say?

Share your comments on this topic with other web professionals

In: Articles

By Tom Green

Published on November 27, 2006

In the first two articles in this series, I traced the rise of the Flash video as a streaming media format, and demystified much of the hype around Flash video. In this installment, let’s get down to business and actually put a video on a site. You won’t need to learn how to do Flash animations—or learn anything else about Flash—in order to put videos online. You can jump right into preparing videos with Flash just by reading this article and some of the other resources I’ll recommend at the end. I’ll deal with the entire process, from someone handing you a video to a user actually viewing the Flash video in a browser, and you’ll do it without needing to know any code. Though the process is dead simple, the entire workflow can be both technical and, especially if you are new to Flash video, a little intimidating.

The tools you need to get going are not as extensive as you may think. They are:

That is the bare-bones package. The players allow you to preview the video, the encoder allows you to create the video, and Flash Professional 8 lets you create the video application.

If you are serious about encoding Flash video, then consider picking up a copy of either of these two commercial Flash video encoding solutions:

If you are at all serious about creating Flash video, either one of these two tools is indispensable because they offer something not available through the Flash Video Encoder: two-pass variable bit-rate encoding.

Two-pass VBR encoding is what makes for a higher quality video than the constant bit-rate encoding offered by the Flash Video Encoder. In very simple terms, two-pass VBR trots through the video twice. The first time it runs through the video, it analyzes the changes in motion and so on. In the second pass, it does the actual compression. Constant bit-rate encoding, CBR, does the analysis and encoding at the same time. The result is a lower-quality video than that resulting from the two-pass. To actually see what I am talking about, head over to Flash Video FAQ and do a side-by-side comparison of the results of encoding through the Flash Video Encoder, FlixPro, and Sorenson Squeeze 4.3.

Screenshot of FlashVideoFAQ
Image 1: FlashVideoFAQ lets you do side-by-side comparisons of the Encoders.

To take a deeper look at these two products, Elliot Mebane has recently published an excellent overview of them—and their strengths and weaknesses—at the Adobe Developer Center.

Step one: Preflight the video

With the tools in hand, someone hands you a video and it is now time to actually prepare the FLV file. The first thing you want to do is to ensure that you have the highest quality video in your possession. Open the video in the QuickTime Player or the Windows Media Player and see if Lossless Compression—uncompressed AVI for example—has been applied to the video. You can retrieve this information by selecting File > Properties in the Windows Media Player or Window > Show Movie Info in the QuickTime Player. If it isn’t lossless, then seriously consider returning the file, as I suggested in part two of this series, and request a version that is not lossy.

Sample QuickTime Info window
Image 2: The QuickTime Info window lets you see what you are working with.

Sample WMP Properties dialog box
Image 3: The Windows Media Player Properties dialog box.

The next step in the process is to actually watch the entire video—twice. The first time through, just enjoy the show and get it out of your system. The second time you watch the video, watch for movement, artifacts (little blocks or banding in areas of solid color which are indicators of lossy compression) and listen to the audio. What you find will help you determine your encoding strategy. This is one of the most important steps in the process. Scott Fegette at Adobe and I co-authored an article that walks you through this process. You can see it either at Community MX or at the Adobe Design Center.

Finally, if you insist on shooting your own video, you might want to read this rather informative piece, also by Scott Fegette. There are plenty of practical tips that will help you navigate the video minefield.

Step two: Encoding the video

This next step in the process is what separates you from the YouTube neophytes. As I pointed out in part two of this series, it is not Flash video that sucks on YouTube, it is how the FLV was encoded that makes it such a bad experience.

The Flash 8 Video Encoder is actually composed of two discrete areas: the encoding queue and the encoding settings. One really interesting aspect of the queue is that each video in the queue can have its own custom settings. The implication here, of course, is that the queue can be used for batch processing purposes.

FLV Encoder render queue
Image 4: The FLV Encoder’s render queue can be used for batch processing of FLV files.

The Encoder window is where the actual encoding settings are applied. You access it by clicking the Settings button in the queue window. The biggest mistake you can make is to blithely assume that the list of presets in the Profile pop down is all you need to know. They are, to be gentle, not exactly correct.

The default setting is “Flash 8—Medium Quality (400kbps)”. Select this and you would assume that this will encode a video for broadband playback, but you’d be wrong. An FLV is composed of two tracks—video and audio. The data rate is the sum of both data rates. If you click the Advanced Settings button in the Encoding window, you will see the video data rate is, indeed, 400kbps. Look down to the bottom of the page and you will notice the audio data rate is 96kbps (stereo). The data rate, therefore, is not 400 but 496kbps. This rate is great if you have an internal intranet or a T1 one line but will not play smoothly using either cable or DSL access. The best advice I can give you regarding this window is to avoid the presets and do it yourself.

Default values for Flash Video Encoding Settings dialog
Image 5: Use the default values only as a last resort.

To do it yourself you need to know the Flash Player version being targeted and how the user will be accessing the video. For example, if you are adding a video to an intranet, and your company’s IT department is absolutely draconian about allowing people to install software on the company’s computers, the odds are virtually one hundred percent that the people affected by this policy do not have Flash Player 8 or 9 installed. In this case you will have to use the Sorenson codec. Though I may playfully be taking a swipe at the IT department, if your intention is to reach the broadest possible market, then Flash Player 7 and the Sorenson codec are your only options. However, at this point, Adobe says that ninety-three percent of the market has at least Flash Player 7, and seventy-nine percent or so already have Flash Player 8.

If your video contains an alpha channel (transparency such as the weather reporter in front of a green screen) or uses the FLVPlayback component, Filters, or Blend effects contained in Flash Professional 8, then your only choice is the ON2VP6 codec, which only works in Flash Player 8 and 9.

Knowing how users will be accessing the video is, in many respects, even more important than the player version you will choose. Imagine having dial-up access and the video is sized and encoded using the encoder’s default. Not only will it take forever for the file to download and play, but the playback will be, to be gentle, horrendous. The reason is the data rate. You will be overwhelming the player, attempting to push a watermelon through a worm.

Here are some rough guides for data rate and size for broadband and dial-up:

Dial-up: 120×90 and a total data rate of less than 100kps.
Broadband: 320×240 or 240×180 and a total data rate of less than 350kbps.

These are rough numbers. If you are looking for a more complete set of guidelines, William Caulfield has published a rather extensive article on best practices in encoding, which reviews encoding video for a variety of delivery situations.

Other factors that can affect the experience are frame rate, the physical size of the video, and the audio data rate. As you get going you will determine the settings that work best for you. Until then, these settings tend to work in a variety of situations:

Size: 320×240
Frame rate: 15 frames per second
Audio date rate: 64kbps (mono)

Size: 640×480 (full screen) - See more about full screen video here.
Frame rate: 5 frames per second
Audio date rate : 48kbps (mono)

Another good benchmark for frame rate is to set it to half of the frame rate used to encode the video in the first place. In North America we use the NTSC standard, which is 29.97 frames per second. This is always rounded up to 30 frames per second when it comes to digital video meaning the FLV frame rate can be 15 frames per second. In Europe the standard is PAL which is 25 frames per second. In this case the frame rate can be either 12 or 15 frames per second.

The audio data rate is another area where many of the decisions you will make will be subjective, not objective. If clarity of sound is a major objective, then selecting one of the Stereo Data Rate presets is the way to go. Just be aware that the higher the value, the more weight you will be adding to the final file size. Select mono if the clarity of sound is not a huge issue and the user couldn’t care less if a high-quality sound track blasts out of his stereo speakers. A great candidate for mono sound is a voice-over or narration.

The final consideration is placement of keyframes. In a digital video, there are two types of frames. Keyframes have all of the information in the frame retained. Difference (or delta) frames only contain, in very simplistic terms, the visual data that changes between the frames. As you may have surmised, the size of a delta frame is considerably smaller than a keyframe. Spreading out the keyframes—for example one keyframe every 300 frames—is how FLV files finish up being so small. Though you can manually set the spacing of the keyframes in the Encoder, this is one of those instances that, if you don’t have a lot of encoding experience, you may want to let the software do the work, so select Automatic in the keyframe placement pop down menu.

Flash Video Encoding Settings, ready for encoding
Image 6: Disgruntled Dan is ready to be encoded.

Once you have put your settings in place, click the OK button to return to the Render queue. When you return, click the Start Queue button and you will see the progress of your encoding. The end result of the process will be an FLV file which will be placed in the same location as the source file being encoded. It is at this point where a lot of people new to this process are a bit astounded. The file size for the final video has plummeted. For example, the QuickTime version of the video being used in this section weighs in at 38.2 MB, while the FLV created using the encoding settings has a final size of 8.6 MB. What you are seeing is a combination of how a lossy codec, frame rate, video data rate, audio data rate, and final physical size affect the process.

Video encoding progress bar
Image 7: The video is being encoded.

Before we leave the encoder, a common request for video is how to make it accessible. The best way of doing that it to add closed captions to the video. This is a rather extensive discussion which is out of the scope of this piece, but one aspect of the Encoder—cue points—is critical when adding captions. Though you can add the cue points using the Encoder, I am a bit leery of hard wiring anything into an FLV. If you are wrong on the timing of a cue point you are facing the task of re-encoding a video because once a cue point is embedded, it isn’t able to be removed. This explains why many Flash video creators tend to add these things using ActionScript, or use third party tools for closed captions. If you are looking to add closed captions to a small video, I have written a how-to. If you are looking for an industrial-strength, third party solution, one of the best out there is a product called Captionate.

Playing the video

Having created the FLV, the time has arrived to head to Flash and prepare it for web playback. In the interests of keeping this article focused, I won’t be getting into using ActionScript to play a video or using the Flash Media Server to play the video. These aren’t essential for putting a video online. Instead, I will walk you through the use (and abuse) of the FLVPlayback component found in the Flash Professional 8 Component library.

When you open Flash, the first thing you want to do is to immediately save the new .fla file (FLA) to the directory containing the FLV and which will be uploaded to your web server. Do this now and you will avoid a ton of grief later on, as you will see.

When the new document is open and saved, open the Components panel by selecting Window > Components. Open the FLVPlayback – Player 8 component and drag it from the panel to the stage. This component is your entry into the world of Flash video. It is dead simple to use but there are a couple of gotcha’s that will bite you if you aren’t aware of them. The first thing you need to know about this component is that it isn’t a movie clip. Like all Flash components, this one has its own methods and properties. Unlike most Flash components, this one is really, really easy to use and requires zero knowledge of ActionScript.

With the Component on the stage, select and click the Parameters tab in the Property Inspector, or select Window > Component Inspector. The list of parameters can, at first glance seem to be a bit bewildering. In actual fact, they are pretty concise. Let’s review them:

Note:
In the image below, I use the Component Inspector to set the parameters. This is because the window containing the Parameters in the Property Inspector can’t be expanded. I wanted you to be able see them all in one place.

Flash Video ready for playback, plus use of the Component Inspector
Image 8: The parameters are set and the video is almost ready for upload.

Targeting Flash Player 6 or 7

There will be occasions where the target player is Flash Player 6 or Flash Player 7. In these cases you can’t use the FLVPlayback component. You need to use the MediaPlayback component found in the Media Player – 6 – 7 area of the Components panel. Using this one is almost as easy as using the FLVPlayback component. Once you drag the component to the stage, select it, open the Component Inspector and click the parameters tab in the Component Inspector. As you can see in Image 9, the major differences, apart from the classic Halo style used by Flash components are that you have to enter the length of the video and a frame rate, and also determine the location of the controls. One major gotcha with this component is that it will not play a video encoded using the ON2VP6 codec.

Media Playback Component
Image 9: Use the Media Playback component if Flash Player 7 or Flash Player 6 are your targets.

With the parameters set, you might want to press ctrl+enter (PC) or cmd+return (Mac) to test the movie. If you don’t see a video playing, check the path to the FLV, and be sure the FLA and the FLV are in the same directory.

Assuming all is working as it should, the next step in the process is to trim off the excess weight by setting the Flash stage to the same size as the FLV. Be careful here because another gotcha will rear its ugly head.

If you select Modify > Document and select the Contents button in the Match area of the Modify Document dialog box, you will see that the dimensions of the contents are 320×240. If you click OK, the Flash stage will shrink to the size of the video, but the controls will be left hanging off of the edge of the stage. If you do this, the controls will not be visible when you place the SWF into the HTML document. This is more an issue with the External controls (rather than the Over controls) you chose in the parameters. If you are using an External control, add another forty or forty-five pixels to the height of the stage.

Hiding the controller
Image 10: Selecting contents without adding some extra height to the stage will result in the loss of the controller on your web site.

Publishing the SWF

Having removed the unwanted space from the stage, the time has arrived to publish the video and get it up on your web site. When you select File > Publish Settings you have the choice of publishing just the SWF or the SWF and the HTML (in the Formats area of the Publish Settings dialog box). Being a hard core Dreamweaver 8 user, I rarely publish the HTML and, if you prefer to do it by hand, then you too can deselect the HTML option. All the HTML option does is create an HTML page with the necessary Object/Embed tags, and not much else.

Again, be aware of a gotcha that catches the uninitiated. If you look at the path to the SWF, you may just see another absolute path pointing to a location on your hard drive. This is a really bad idea. If you see the path, click the Browse button and navigate to the directory containing the FLA file and the FLV file. When you return to the Formats area, click the Use Default Names button and this will strip off the path to the directory.

If you are targeting the Flash Player 7 or the Flash Player 6, click the Flash tab in the Publish Settings, and select the player in the version pop down. Just keep in mind that if you are using the FLVPlayback component and select either the Flash Player 7 or the FlashPlayer 6 you will see an alert box suggesting this might not be such a good idea.

Return to the Formats area and click the Publish button. A small dialog box will appear showing you the publish progress. When it disappears, click the OK button to return to Flash. Save the FLA and quit Flash.

Settings for publishing an SWF
Image 11: Publishing the SWF.

If you open the directory where you saved the SWF you will see the following files:

Whatever you do, don’t move the SWF and the controls to different directories. Do this and the video will be broken. Always keep them in the same folder. In fact, if you can, keep the HTML, the FLV, the SWF and the controls SWFin the same folder. Do this and you are guaranteed the video will always play.

Grouping of files
Image 12: Keep the Controller and the Flash SWF in the same directory.

Once the SWF is placed on the web page, it can be treated no differently than any other content on the page. For example, you can use CSS to run text around the video, or place the video in its own location on the page.

Conclusion

This article completes the series on “The Rise of Flash Video.” If you have been following the series, I traced how Flash video muscled out the big boys to become a standard in very short order, and dealt with many of the quality and security concerns raised around the use of Flash video.

This installment walked you through the Flash video process, starting from being handed a digital video to uploading the video and using it in a web page. As you may have surmised, though the process is fairly uncomplicated, there are plenty of opportunities to make mistakes. One of the most common, when it comes to using the FLVPlayback component, is not using a relative path to the FLV. Another is placing the video SWF in one directory and the controls SWF in another.

I also covered creating the FLV using the Flash 8 Video Encoder that ships with Flash professional 8 and, again, pointed out areas where making mistakes or assumption around data rate can result in a poor experience for the user.

Obviously, there is a lot more that you can do with Flash video, especially if you are familiar with ActionScript. You can, for example, create some rather interesting effects by applying Blend Modes and Filters to the video. You can create playlists that allow one to choose among a number of videos, have a sequence of videos play, and even have one video transition into the next one when it finishes playing. Still, the process starts with mastering the basics and expanding your knowledge from that point outwards.

As I am fond of saying, “The amount of fun you can have with Flash video should be illegal.”

I’ll see you in jail!


Flash video links:

Here is a list of links you might wish to explore as you become more comfortable with Flash video:

Accessibility:

Books:

Other sources:

Got something to say?

Share your comments  with other professionals (2 comments)

Related Topics: Flash, Convergence

 

Tom Green is a professor of Interactive Multimedia, through the School of Media Studies at Humber College in Toronto. He is also a speaker, and the author of six books, including two recent ones on Flash and Flash Video. An Adobe Community Expert and a Community MX partner, he believes the amount of fun we have in this business should be illegal.

Media Temple

via Ad Packs