Streaming Video and Bandwidth

A popular feature of the Communication Server is its native ability to stream audio and video. Flash Player 6 supports video prepared using either Macromedia Flash MX's built-in Sorenson Spark audio/video compressor or the external, third-party tool, Sorenson Squeeze. The Squeeze product includes a "professional" upgrade to Sorenson Spark, called the Sorenson Spark Pro codec. Higher quality video and bandwidth optimization are just two key benefits. Using videos encoded with either technology, you can natively embed video or dynamically load video (SWF or FLV files) from a remote server using the Flash MX loadMovie() method with no Communication Server.


Sorenson is the company that developed the compressor, or codec algorithm, for Macromedia. Sorenson made its name supplying the codec used by Apple QuickTime. A codec (short for code/decode) is required to encode a video from one format to another. Every player that can play a video format requires the decode codec. The only codec supported by the Flash player is Sorenson Spark. For more information on the codec visit


For Flash to display video, it must be encoded using the Spark compressor. Files must be of type FLV or SWF. You cannot dynamically load AVI, QuickTime, or DV files without first compressing them. You can import these formats into Flash if you do not plan to load them dynamically.

So if you can load a movie dynamically with Flash, what does the communication server do differently? The process of streaming adds a lot of benefits. The most obvious is the ability to stream live video. Table 7.1 compares the features of dynamically loading a video using the loadMovie() object and using the Flash Communication Server's NetStream() object.

Table 7.1. Comparison chart between methods of loading server video dynamically.

Dynamic Video Using LoadMovie()

Dynamic Video Using NetStream()

Video is forced to match the frame rate of the calling Flash movie.

Video retains its encoded frame rate (fps).

RAM is allocated on the client to store the entire movie before loading begins. This can cause problems, particularly on Mac where memory is set as a finite amount per application.

RAM is allocated for only the length of the buffer for the stream. This is great for devices that don't have a lot of RAM; for example, mobile devices.

Flash has a 16,000 frame limit on any movie, which supports only a few minutes of video (22 minutes at 12fps).

Video can be sent from the server 24x7. There is no limit.

Seeking a video forward (fast-forward) before it has been loaded is not possible until it has completely loaded.

Recorded video can be seeked forward to any spot, whether it has loaded or not. You can also display a single "poster-frame" at any point in the movie.

If bandwidth becomes restricted before the video is loaded, the video will pause to continue loading.

Streamed video will drop frames to keep sync and ensure a seamless transmission if bandwidth becomes restricted.

Video quality cannot be switched in real time to increase or decrease bandwidth load. To change bandwidth, a separate loadMovie() command must be issued, and video will restart.

Video quality can be switched in real time to increase or decrease bandwidth load. This allows one stream to work in multiple bandwidth configurations so there is no need to encode a stream in multiple bandwidths for different clients.

This is not possible with loadMovie().

Video stream can be stopped while audio continues to save bandwidth (if required).

This is not possible with loadMovie().

Audio stream can be stopped while video continues to save bandwidth (if required).

Excited yet? Now Flash Player 6 is acting like one of the big three streaming media players: RealOne player, Windows Media Player, or QuickTime player.

A Quick History Lesson on Streaming

You may be familiar with the concept of "streaming" through such Internet devices as the Real Player (now called RealOne), Windows Media Player, or QuickTime. Streaming is the process of delivering synchronized pre-recorded or live video and audio to multiple computers in real time. In 1998, the hype on streaming media was in its highest state: Radio stations were streaming their signal, Internet TV shows started, and there was even a case in Toronto, Canada where a company (iCraveTV) streamed every television station transmitting over the public airways. This whole fetish began in 1994 with the famous Internet transmission of the Rolling Stones Voodoo Lounge concert to 1,000 computers around the world. The technology of the day was called MBONE (multi-casting backbone), and it wasn't pretty.

Today, Internet streaming still hasn't completely sorted itself out, and expectations are that there are at least another 10 years or so before it will. But that is just this author's opinion. Video conferencing, another form of streaming media, was heralded as the next killer app. The product, CU-SeeMe, was the leader in providing video conferencing software for desktop computers. An interesting connection between the Rolling Stone's MBONE concert and CU-SeeMe, is that the San Francisco company who organized the Stone's concert, Internet Access played a part in the rollout of the CU-SeeMe company. Back in the day, CU-SeeMe created a communication server called Reflector that allowed 20 or so people to connect to "see" each other. There was actually an initiative in place to "schedule" Reflector times.

In 1995 Progressive Networks (known today as Real Networks) created the Real Player. This revolutionary technology was built to communicate using a new protocol. Like Macromedia, Progressive Networks realized it needed its own protocol specially designed to handle media. HTTP, after all, was not intended for sustained connections, a requirement for delivering time-based media like video. The rtsp:// (Real Time Streaming Protocol) was created by Progressive Networks to send live or recorded video and audio over the Internet. In 1995, the population of people on the Internet was small, and those that were online connected at average speeds of 14Kbps and 28Kbps. Compare that to today, where home users connect at an average speed of 1,024Kbps (1Mbps) or higher. Microsoft soon followed, introducing their streaming server solution with a major enhancement to its Windows Media Player as the preferred client. Before the third player, QuickTime, began its streaming career, a new XML authoring format called SMIL (Synchronized Multimedia Interface Language) was created. This language was based on XML and was used to handle multiple streams of synchronized data. This technology was adopted quickly and content producers, such as CNN, quickly built applications to stream video, audio, dynamic text, and image content, such as news and weather.

Apple QuickTime seemed to be the last in the streaming server market, but it had already established a standard of high-quality video in partnership with Sorenson Media. Sorenson recently worked with Macromedia to create a new media encoder algorithm to compress video into files that can be read by Flash Player 6. Overnight, with the release of Macromedia Flash MX, Sorenson increased its user base by incredible numbers.

So, how does this get back to the developer? One major element that eats at the Internet developer is surrendering to one of "The Big Three" to deliver video over the Internet. Macromedia has changed everything with the Flash Communication Server. The Big Three have fought for market share for years. They each support Flash movies, but always saw the Flash player as a an enhancement, not a competitor. Here is an interesting statistic: The Flash player is the single most adopted software in the history of the world by both the business and consumer market. Its market share is bigger than The Big Three media players combined; it's bigger than the Microsoft Windows operating system! Macromedia's framework for the developer to produce streaming media within the Flash player has changed the rules, once again over night.

Ok, that's enough history. To get the best understanding, let's start streaming!

Playing a Prerecorded Video

Our first Flash Communication Server exercise in video is streaming a prerecorded video from the server to the Flash player. Flash MX supports most major video file formats including the following:

  • Windows (AVI, WMV, ASF)

  • Digital Video (DV)


  • Apple QuickTime (MOV)

To use video, Flash must first convert the video into a format it can use and control. You have two options for file formats in Flash: a Flash movie (SWF) or a Flash video (FLV) file. When you stream video, you must use the FLV format. The SWF and FLV formats are encoded using the Sorenson Flash video codec, Sorenson Spark.

Video compression techniques alone can fill a book. If you plan to incorporate professional video with any Flash application, consider investing in one of these books. This book will introduce you to both technologies and provide some recommended compression settings in both Flash MX and Sorenson Squeeze, but the focus is on the streaming of video.

Exercise 7.1: Flash Video Compression Using Flash MX

In this exercise you will convert an existing QuickTime video into a Flash video file using the built-in Sorenson Spark compressor in Flash MX. If you do not have a video to work with, you can download a video from the book's web site.

The Sorenson video encoder (see Figure 7.1) built into Flash MX is easy to use. The file that will ultimately stream is not loaded into your movie within Flash MX. It will be called into your movie using NetStream() at a later stage. Follow these steps to convert your movie into a Flash video file using Flash MX.

Figure 7.1. Sorenson Spark is the built-in video compressor for Flash MX.


  1. Create a new document with Flash MX. You will not be saving this document, just using it to compress the Flash movie.

  2. Import the video into Flash MX the same way as importing any asset. Click File, Import to Library, and then browse and select the video to convert.

  3. Click OK. Flash MX will give you two import options (see Figure 7.2). Select the Embed Video option, and then click OK.

    Figure 7.2. Flash MX will give you two options when you import a video to the library. To build FLV files, select the Embed Video option.


  4. The Import Video Settings window (see Figure 7.3) displays conversion settings you can control for this movie. This is your only time to edit these settings. Experiment with the following settings to get a feel for how they affect the video:

    • Quality. Allows you to select a range between 0 and 100. Setting Quality to 0 results in maximum compression, 100 is least compression and lossless quality. Recommended settings are between 60 and 80.

    • Keyframe Interval. Creates video keyframes when there is a large change in the pixel color (resulting in movement) between frames. Setting Keyframe Interval to 0 turns off keyframes, a value of 30 keyframes every frame. If you set the keyframe rate too high, your file size will increase dramatically. Setting the rate too low results in a very poor quality video. If you have a lot of motion (as in a movie trailer), use more keyframes. If there is not a lot of motion (as in a talking head shot), lower your keyframe interval.

    • Scale. Changes the size of the video frame in proportional values of width and height.

    • Synchronize Video. Conforms the video to the current frame rate of your Flash MX movie. To retain the original frame rate (recommended), turn off Synchronize Video. Doing so, however, might produce a choppy playback. If your video frame rate (fps) is too high, some computers may not have the processing speed to playback smoothly.

    • Frames Ratio. Plays one frame of video per one Flash frame. It's recommended to leave this ratio at 1:1.

    • Import Audio. Includes the audio channel in the encoding process.

      There is no way to describe which setting is best. Each unique video will compress differently. Some factors to consider are the amount of motion in your video, the speed, the sound, and the way it was captured. For example, if you digitize a video from a digital camera, you will get much different results than if you digitize from a VHS tape because of the quality difference of the recorded matter. If you have a video feed in low light, you will get different results than with ample light.

      Clearly the best quality will result in setting all settings to 100%, but this will potentially result in a large file with a lot of unneeded elements, not to mention you risk consuming unneeded resources on the client's computer. You should experiment by importing a video and max out the settings, and then import it again with the minimum settings.

      Figure 7.3. The Sorenson Spark built-in compression options.


  5. Click OK when you are finished setting the compressor. Flash MX will then compress the file and place it within the Library.

  6. Open your Library by pressing F11 (or choose Window, Library), as shown in Figure 7.4. You will see the new video (still named by its original source name).

    Figure 7.4. The Library panel menu gives you access to the Properties option for the selected library item.


  7. Select the video, and open the Library panel properties (you can also Right-click (Cmd-click for the Mac) to open this menu. Click Properties.

  8. Export the movie to a Flash video file by clicking the Export button in the Properties window (see Figure 7.5).

    Figure 7.5. The properties of the embedded video gives you the option to export the clip as a FLV file.


  9. Save the video to your hard drive. This file will ultimately be placed in your Flash Communication Server application folder. Don't do it yet.

That is all you need to do to convert your digital video in Flash MX to a format that can be streamed by the Flash Communication Server. Exercise 7.2 will introduce you to the difference between compressing using Flash MX and using the Sorenson Spark Pro Compressor within Sorensen Squeeze.

Exercise 7.2: Video Compression Using Sorenson Squeeze

If quality is what you need, consider investing in Sorenson Squeeze, which contains the upgraded Sorenson Spark Pro compressor?the big brother of the compressor used in Flash MX (see Figure 7.6). For about $200, Squeeze has many features that can increase the quality and delivery of your video. Squeeze is a great product with a lot of features, including batch processing to save you time compressing large files. The following exercise will introduce you to some of these features.

Figure 7.6. Sorenson Squeeze contains the upgrade to the internal video.


Using the same QuickTime video used in Exercise 7.1, this exercise will step through the process of converting video into Flash video destined for streaming with the Flash Communication Server. You can download some sample video clips from this book's web site.

  1. Open Sorenson Squeeze.

  2. Open a video file using the folder icon or simply drag the video onto Squeeze. The video will be displayed in the player window (see Figure 7.7).

    Figure 7.7. The Sorenson Squeeze encoder.


  3. Click the Flash Video icon in the toolbar above the video (see Figure 7.7).

  4. Open the Compression setting for Broadband by clicking Edit, Compression Settings, Broadband (see Figure 7.8).

    Figure 7.8. Edit the Compression settings by selecting the option in the Edit menu.


  5. In the Compression Settings window (see Figure 7.9), make sure the Flash FLV tab is selected. This window is the compression settings for Broadband video. Squeeze allows you to simultaneously compress different versions of your video for high bandwidth and low bandwidth connections.

    Figure 7.9. The Compression settings within Squeeze add much more control than Flash MX.


    As you can see, Squeeze already offers you much more control over your video compression than Flash MX did. Let's take a quick look at the settings:

    • Video Compressor. You only have one choice here for Flash Video: Sorenson Spark.

    • Audio Compressor. Two options are available to you: Fraunhofer MP3 or RAW audio. Each compressor has different qualities depending on the type of audio you have (talking versus music, for example). It is recommended to use MP3 encoding with a lower bit rate.

    • Video/Audio Data Rate. The value here is related to the amount of bandwidth your client has. For example, a modem can support a bit rate of 56 kilobits per second (Kbps). The estimated bandwidth is video data rate plus audio data rate, so a 56K modem will not support video and audio with video encoded at 56Kbps. Other than MP3 audio, all audio data rates are set using the independent vendor options window. Please read the section on Bandwidth later in this chapter.

    • Video Frame Rate. This is also known as frames per second or fps. Normal NTSC video from a video camera has a frame rate of 30fps (well, actually 29.97, if you are a perfectionist). Images shot using a film camera are recorded at 24fps. Usually video displayed over the Internet uses 15fps. This means you will see 15 images per second (about half of the original source). At 15fps you will not visually notice much of a difference in the video. Once you dip below 15fps, you will start to notice your video is jumpy. The higher the frame rate, the smoother your video. It is recommended using the ratio options (1:2) for this setting to gain maximum quality.

    • Video Method. You have two choices: constant rate or variable rate (2-Pass VBR). For the highest quality, select the variable rate. For fastest compression time, select constant rate. For any production, you should use the 2-Pass VBR option.

    • Video Frame Size. This is the actual frame size of your video. It is recommended selecting a 4:3 ratio for North American Video (NSTC); however, you can select the width and height independently. Recommended settings are either 320x240 or 160x120.

    • Audio Sample Rate. This is the audio equivalent to dots per inch when scanning a photograph. It represents the samples per second the compressor will use to compress the audio track. CD quality is 44,100kHz, but you can usually get away with 22,050kHz.

    • Channels. The two choices are Stereo and Mono. Stereo immediately doubles the size of your audio. A talking head or a single voice track should be Mono. Music, if stereo is important, should be set to Stereo.

    • Sorenson Spark Pro Options. The professional version of Spark gives you even more control over your video compression, handling drop frames, keyframes, and allowing a minimum quality threshold (see Figure 7.10).

      Figure 7.10. The Options button displays the expanded Sorenson Spark encoder options. Change these settings using the Encode/Playback tab.


  6. Click OK to return and exit the Compression Settings window.

  7. Apply filters to your video by clicking Edit, Filter Settings (Ctrl+F). Filters allow you to affect the movie before it gets converted. You can adjust the standard Brightness, Contrast, Gamma, and Black and White Restore levels (Figure 7.11). You can also de-interlace and crop your video, add fades to the ends of your video, and clean the audio track with a normalization process.

    Figure 7.11. The Options button displays the expanded Sorenson Spark encoder options. Change these settings using the Encode/Playback tab.


    Figure 7.12. Click the Bandwidth bars to select the compression settings for output. You can select multiple settings to encode at the same time.



    Cropping your video by two pixels on all four sides will help remove unwanted video noise on the edges during capture. This trick usually helps keep the file size down. Also, turn on Auto Remove Interlacing and Normalize Audio.

  8. Assign the compression settings you want to encode. Select Compression, Broadband. This will place the job in the Output Files window.

    The Output Files window displays compression jobs queued to be "squeezed." It will detail the highlights of your compression settings.

  9. Add a low-bandwidth version of your video to the queue by clicking Compression, Modem. A second job will be placed in the queue.

  10. Select the Output Folder by clicking Edit, Output Folder. This folder will contain the finished FLV file.


    Using an output folder on the same hard drive as the source file will speed up the encoding process. Outputting the file over a network share should be avoided. If the network is disconnected during the compression, your file will be corrupt and the encoder will fail.

  11. Click the Squeeze It button below the Output Files window to begin the encoding process. A Progress window will be displayed; it will take two passes on the video (see Figure 7.13). The first pass is almost equivalent to the Flash MX output. During the second pass, you will notice a significant improvement in the preview.

    Figure 7.13. Squeeze will display the status and the current file it is working on.


Squeeze compresses all files queued in the Output window, and displays a report when complete. At the end of the process, you will be left with two files?one with the suffix _broadband and one with the suffix _modem. These naming conventions will be useful when the files reach the Flash Communication Server.

Sorenson Squeeze also includes a Folder Watching utility. This handy tool monitors a folder of your choice for any new video files. Simply by placing a file within this folder with Squeeze running, you trigger Squeeze to compress it. We won't get into that specific feature, but you should investigate it.

With your Flash video files ready, you are now prepared to stream them using the Flash Communication Server.

    Part I: 10 Quick Steps for Getting Started