Capturing live video

Using Flash Media Live Encoder to capture video

Flash Media Live Encoder is a free application that captures live video, encodes it, and streams it to Adobe Media Server. By default, Flash Media Live Encoder is configured to stream video to the live service at rtmp://localhost/live.

Adobe Media Server installs with a sample video player that can play streams from the live service. The video player is installed to the folder rootinstall\samples\videoPlayer.

The sample video player is based on Strobe Media Playback built on Open Source Media Framework. For more information, see Pre-built media players.

For more information about Flash Media Live Encoder, see

Example: Custom video capture application

The following steps build an application in ActionScript 3.0 that:

  • Captures and encodes video.

  • Displays the video as it’s captured.

  • Streams video from the client to Adobe Media Server.

  • Streams video from Adobe Media Server back to the client.

  • Displays the video streamed from the server.


To test this code, create a rootinstall/applications/publishlive folder on the server. Open the rootinstall/documentation/samples/publishlive/PublishLive.swf file to connect to the application.

1. In a new .as file, create a NetConnection object. To connect to the server, pass the URI of the application to the NetConnection.connect() method.

var nc:NetConnection; 
var ns:NetStream; 
var nsPlayer:NetStream; 
var vid:Video; 
var vidPlayer:Video; 
var cam:Camera; 
var mic:Microphone; 
nc = new NetConnection(); 
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); 

2. Define a function to handle NetStatusEvent events. If the client makes a successful connect to the server, the code calls functions that run the application.

function onNetStatus(event:NetStatusEvent):void{ 
    if( == "NetConnection.Connect.Success"){ 

3. Publish the video being captured by the camera and the audio being captured by the microphone. First, get references to the camera and microphone data. Create a NetStream object on the NetConnection you made to the server. Then call NetStream.attachCamera() to attach the captured video to the NetStream object. Call NetStream.attachAudio() to attach the live audio. Finally, call NetStream.publish("streamName", "live")to send the audio and video to the server.

function publishCamera() { 
    cam = Camera.getCamera(); 
    mic = Microphone.getMicrophone(); 
    ns = new NetStream(nc); 
    ns.publish("myCamera", "live"); 

4. Display the video the client is streaming to the server. Create a Video object. The Video object is a display object. Call Video.attachCamera(cam) to attach the camera video feed to the video object. Call addChild(vid) to add the Video object to the display list so that it appears in Flash Player.

function displayPublishingVideo():void { 
    vid = new Video(); 
    vid.x = 10; 
    vid.y = 10; 

5. Display the video the server is streaming to the client. A client that creates a stream to send to a server is publishing, while a client playing a stream is subscribing. The client in this example publishes a stream and subscribes to a stream. The client must create two streams, an outgoing (publishing) stream and an incoming (subscribing) stream. In this example, the outgoing stream is ns and the incoming stream is nsPlayer. You can use the same NetConnection object for both streams.

To play the audio and video as it returns from the server, call and pass it the name of the stream you published. To display the incoming video, call Video.attachNetStream():

function displayPlaybackVideo():void{ 
    nsPlayer = new NetStream(nc);"myCamera"); 
    vidPlayer = new Video(); 
    vidPlayer.x = cam.width + 20; 
    vidPlayer.y = 10; 

Use ActionScript to allow users to control playback, display video fullscreen, use cuepoints, and use metadata. For more information, see the “Working with video” chapter in ActionScript 3.0 Developer’s Guide.

More like this

Adobe logo

Sign in to your account