Accessibility

Flash Article

 

Encoding Best Practices for Live Video


Kevin Towes

Kevin Towes

Adobe

Comments
Created:
28 May 2004
User Level:
Beginner

The Flash Video platform supports live video encoding and delivery when used with Flash Communication Server MX. Macromedia Flash Player (6 or greater) contains an audio and video encoder that lets you capture audio and video directly from any camera or microphone that is connected to your computer. While capture cards and other live video-encoding hardware should improve live video quality by pushing a better video signal into Flash Player and by handling much of the processing through the hardware, you don't necessarily need them to achieve basic live video streaming.

The Flash Player video encoder supports live video, audio push, record, and record-append. This support lets you build Flash-based live video streaming, video chat, video messaging, webcasting, video conferencing, and stop-motion capture. You can also use the prebuilt Flash components to assemble your live video conference quickly or to create a video recorder using Flash Player.

Another option for hosting live video is Flash Video Streaming Service (FVSS).

FVSS (www.macromedia.com/go/fvss) is a hosted solution built with Macromedia Flash Communication Server MX and industry-leading content delivery network partners. FVSS provides video on demand and live streaming. If you've spent considerable effort making sure your video is of the best possible quality, then you want to make sure the end result is a great experience for your audience. FVSS takes care of all the network hassles, including failover and redundancy, and is managed by industry experts who know how to stream Flash Video better then anyone else on the planet.

Requirements

To complete this tutorial you will need to install the following software and files:

Macromedia Flash MX 2004 Professional

Macromedia Flash Communication Server MX

Level of Expertise Required

Pertains to all skill levels, basic to advanced.

Tutorials and sample files:

Before reading this article, check out these other great Flash Video resources:


Also check out my other article on Flash Video, Best Practices for Encoding Flash Video.

Live Video Encoder Bandwidth Settings

In the Frame Rate, Size, Keyframes, and Data Rate section of my other article, "Best Practices for Encoding Flash Video," you were introduced to determining the bits per second of a clip by multiplying the frame height and width and the rate:

Formula:
frame height x frame width x frame rate (fps) = total bits/sec.
Example:
320 x 240 x 30 fps = 2.3 Mbps

However, when you use Flash for live video encoding, bandwidth is set in bytes per second (Bps), not kilobits per second (Kbps). To determine the bandwidth settings for the video encoder, you must divide the total bits by eight (eight bits equal one byte). Use the following formula to determine bytes per second:

Determine bytes per second bandwidth:
((320 x 240 x 30fps)/8) = 288,000 Bps

To determine your bandwidth limits, convert the number from bytes per second (Bps) to kilobits per second (Kbps) with the following formula:

Convert Bps to Kbps:
(Bps x 8) DIV 1000 = Kbps
Therefore: 
288,000 Bps = 2,304 Kbps or 2.3 Mbps

Live Encoder Recommended Settings

The following matrix demonstrates the data rate formula to determine the setting values for the Camera object in Flash. You can see the live samples in the embedded player below the matrix.

Live Camera Settings (Camera Object)
Camera.setMode
(w,h,fps)
setKeyFrame
Interval (kfi)
Camera.setQuality
(b,q)
Microphone.
setRate (sr)
 
w h fps kfi b q sr  
Width Height FPS KFI Bandwidth (bytes/s) Quality   TOTAL Data Rate (Kbps)
> 1Mbps High Broadband
320 240 15 60 144,000 85 22 1,196
786 kbps Broadband
240 180 12 48 64,800 85 22 562
384 Kbps Broadband
192 144 7 28 24,192 85 11 216
56 Kbps Dial-Up
80 60 8 32 4,800 85 8 54

Live Recording Examples:

 

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Macromedia Flash Player.

Download the free Flash Player now!

Get Macromedia Flash Player

 

Live Video Encoder Study

To determine the recommended live encoder settings for Flash Player, I studied a variety of settings. I built a simple application in Flash to record a series of 30-second clips, monitor the stream progress, and determine the best quality settings for a variety of bandwidths (see Figure 3). The study application let us set the video encoder settings and start a 30-second test.

The live testing tool lets you enter camera-setting values and see the results. Connect your camera or video source and try it out below.

Figure 1. The live testing tool lets you enter camera-setting values and see the results. Connect your camera or video source and try it out below.

View the Live Settings Tester

Note: To use the Live Settings Tester, you must have Flash Communication Server installed on your local machine and a folder within it called videoStudy. Full installation instructions are included in the sample file ZIP below:


Figure 2 shows a snapshot of Flash Communication Server during one of the studies. Notice that two streams were consumed: one for the incoming stream and one for the playback stream. Also notice how the bandwidth is consumed. Flash Communication Server calculates bandwidth as total bandwidth consumption in bytes per second.

The Flash Communication Server application inspector showing the activity of the live video tester (above)

Figure 2. The Flash Communication Server application inspector showing the activity of the live video tester (above)

Live Audio Data Rate

The recommended audio sample rate is determined within ActionScript using the Microphone object and the following method:

Microphone.setRate(sample rate);

The live audio data rate is determined by multiplying the sample rate by two. See the matrix above for the recommended audio sample rates for various target bandwidths.

Note: Streaming video courtesy of Flash Video Streaming Service (FVSS), powered by VitalStream.

About the author

Kevin Towes is the product manager for Flash Media Server at Adobe Systems and is responsible for defining, delivering, and supporting Adobe streaming video products and services. Before joining Adobe, Kevin spent 13 years working to enable customers with Flash based interactive video streaming solutions using Flash Media Server. His Flash Media Server Live Video work with the Canadian Broadcasting Corporation (CBC) led to an Emmy nomination in 2004.