This article is the sixth in a loose series of beginner's tutorials. This particular tutorial shows you how Adobe Flash CS4 Professional, Adobe Flash Media Live Encoder 3, and Adobe Flash Media Server 3.5 team up so you can create live video streams from your own webcam or other sources.
Here are all the articles in the series:
As a Flash teacher and lecturer who tends to spend an inordinate amount of time in the Flash space, I love to show my students how to use a webcam with Flash. It is one of the easiest things to learn and it has immediate rewards. Inevitably, though, the question is asked: Can I stream this live?
Depending on the audience, this is a rather awkward question to answer. If I am dealing with an advanced group that has a deep understanding of ActionScript, the answer is, "It's a little tricky but not terribly difficult to accomplish." For everyone else, the answer is, "You really don't want to go there."
Until the release of Flash Media Server 3.5, there was also a bit of a gray area: Flash shipped with a set of communication components that could be wired together to create a live streaming video application. These components disappeared with the release of Flash CS4 and Flash Media Server 3.5. You would think I would be a bit bummed that my gray area was pulled out from under me. Not even close. Now when I'm asked about streaming live video, my response is, "Can you click a mouse and type one line of code?"
In this exercise we are going to do the following:
To follow along with this article, you'll need the following software and files:
Every now and then an amazing piece of software hits the street. Inevitably, the company puts it out in public beta and you can't help but think, at some point in the process, "Dang, this is sweet. I sure hope I can afford it." I had that reaction when I first tried out Flash Media Live Encoder (FME). If the truth be known, I still have a hard time grasping the fact that this powerful piece of software is a freebie.
Its purpose is quite focused: to grab a video or audio feed, on the fly, and either encode it or stream it out—live. In this part of the exercise, I'll take you through the FME interface and use it to create an FLV. Keep in mind this will be a "drive-by" exercise; I won't get into the nuts and bolts of using FME. My colleague, Greg Hamer, has already done a really good overview of this process in his article, Webcasting live video with Flash Media Live Encoder.
Follow these steps to make the initial configuration in Flash Media Live Encoder:
Make sure you have a webcam (microphone is optional) attached to your computer, and then launch Flash Media Live Encoder. When it opens (see Figure 1), you will see that the interface is essentially divided into two distinct areas: Input on the left and Output on the right. If you don't want the split Input and Output view, deselect the Output Video option. All this does is remove the preview on the right. It has no effect on the final file.

Figure 1. Flash Media Live Encoder interface (click to enlarge)
The input area is further subdivided into separate Video and Audio areas where you can tweak the settings prior to capture or broadcast. If you are unsure of the settings to use, select one of the three presets in the Preset pop-up menu. Still, it doesn't hurt to try this application out, so let's create a simple capture.
Select your webcam from the Device pop-up menu. I am using a MacBook Pro with a built-in iSight camera, which explains why I can select only USB Video Device. Were I to have more than one camera connected to my computer, I would be able to choose either my iSight or the Logitech webcam plugged into my USB hub (see Figure 2).

Figure 2. Cameras connected to your computer
Note: You can use a variety of webcams and even digital video recorders to capture the video. As it says in the FME support documents: Flash Media Live Encoder is designed to work with any Microsoft DirectShow–compliant device or driver. For a list of devices that Adobe has specifically tested, visit the Flash Media Live Encoder Device Compatibility Matrix (PDF, 13K). This list is in no way definitive; it simply lists devices tested by Adobe so far. Your first clue as to its (in)completeness should be the missing iSight camera.
At the bottom of the window, you will see the total bit rate, which is the sum of the audio and video bit rates. This is an important number because it has a direct effect on user experience. If you are unsure as to what numbers to use, head over to Robert Reinhardt's Flash Video Bitrate Calculator.
Having dealt with FLV settings, you can turn your attention to actually creating the FLV file:

Figure 3. Camera rolling and action being recorded
Now that you have created an FLV file, it's time to play it:
Save and test the file. As shown in Figure 4, your webcam or other device has moved from an interesting, fun tool to something really practical and important.

Figure 4. Playing the video capture
Now that you know how to create an FLV file using Flash Media Live Encoder, it's time to put that knowledge to work and create a live broadcast. Here's the interesting thing: the workflow is essentially the same as in the previous exercise. The difference is that, instead of creating a file, you broadcast your stream through Flash Media Live Encoder directly into a web page. Here's how:
At this point, you are almost ready to start your broadcast (see Figure 5). Don't quit Flash Media Live Encoder yet.

Figure 5. Output settings for a live broadcast
In the previous step I used the word "almost" deliberately. You will need to create the Flash file that receives the feed from the live folder of your Flash Media Server:
Add a new layer to the movie and name it actions (see Figure 6).

Figure 6. Ready for a live stream
Click once in the Script pane and enter:
myVideo.isLive = true;
The isLive property of the FLVPlayback component can
have only two values: true or false. This property
works only if the feed is streaming from Flash Media Server. If you were not using Flash Media Server—that is, progressively downloading the video from an HTTP address—and you set isLive to true, then Flash would simply ignore the ActionScript and nothing would happen.
Close the Actions panel and select File > Publish Settings. When the Publish Settings dialog box opens, select Flash (.swf) and HTML (.html) in the Type list.
Having created the "feed" using Flash Media Live Encoder and created the SWF file that receive that feed in Flash CS4, you can put your webcam to work and create a broadcast:
When you have finished, return to Flash Media Live Encoder and click the red Stop button. Quit the browser and close Flash Media Live Encoder.

Figure 7. Live, from the streets, it's me!
This tutorial showed you how Flash Media Server 3.5 and Flash Media Live Encoder combine to give you a simple-to-master live video and audio streaming capability. If this subject has caught your attention, here are a couple of other articles that will get you going:

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Tom Green is a professor of interactive multimedia at the Humber Institute of Technology and Advanced Learning in Toronto, Ontario. He is the author of several best-selling books in the area of Flash and Flash technologies. His latest book is Foundation Flash CS4 for Designers, coauthored with David Stiller, and he updated Foundation Flash CS3 Video with Adam Thomas. Tom has completed DVD videos for Lynda.com and Adobe Systems, and is a partner at Community MX and a regular contributor to Digital-Web.com and Layersmagazine.com. He is also an active member of the Adobe Community Experts Group, speaking at conferences and seminars around the world and contributing regularly to the Adobe Developer Connection in the areas of Flash authoring and video technologies.