Jens Loeffler
31 August 2009
Prerequisite knowledge
Required Products
Sample Files
User level
This article is intended for non-developers. You will, however, need to know how to edit XML/SMIL files and upload files to a web server.
Flash Media Live Encoder (3942 KB)


Additional Requirements


Flash Media Live Encoder 3
You can also use a third-party encoder with Flash support.
Flash Media Interactive Server 3.5


You can also use an FVSS service provider in place of Flash Media Server.
This tutorial provides step-by-step instructions on how to set up a dynamic streaming environment without writing any code. With the release of Adobe Flash Media Server 3.5, you now have some exciting new features available for live video delivery, including dynamic streaming and digital video recording (DVR). During playback, dynamic streaming enables automatic switching to a different stream when bandwidth or performance characteristics change, and DVR capabilities enable the user to pause and rewind live streams.
If you have Adobe Flash programming skills, there are some good resources available in the Flash Developer Center to help you take advantage of these features. If you don't have Flash skills—for example, if you are video engineer who has never used Flash before—don't worry. You can still evaluate live dynamic streaming without asking the development team for help or learning Flash or Adobe Flex on your own.
Although this example leverages Adobe Flash Media Live Encoder, you can also use third-party encoders; the setup will work no matter what your encoding environment is.
This tutorial covers the following:
  • Installation steps for Adobe Flash Media Interactive Server server-side code (DVRCast)
  • A sample application to control the DVR functions
  • Sample players for live dynamic streaming and live dynamic streaming with DVR


Configuring the live encoder for live dynamic streaming
One of the reasons Flash media is the leading format for video delivery on the web is the excellent user experience that the Flash platform provides. Adobe Flash Player is ubiquitous (almost all platforms are supported with 99% penetration on desktop computers), it's easy to monetize, and it provides a common platform for different browsers and operating systems.
Dynamic streaming
Web users are demonstrating a growing appetite for HD-quality video on demand as well as live content. Dynamic streaming, also known as adaptive streaming, is a technology that allows the quality of the stream to improve or degrade to predefined bit rates based on available bandwidth and performance. This capability combined with the high penetration of Flash Player 10 provides the best possible user experience for HD on the web.
On-demand dynamic streaming requires a separate file for each included bit rate. There is a similar requirement for live dynamic streaming; each target bit rate requires an encoded stream to be sent to Flash Media Server or a content delivery network (CDN).
Connection and stream names
The following information is required to publish from an encoder:
  • Flash Media Server URL and application name; for example:
  • Stream names
The stream names are different for live dynamic streaming and live dynamic streaming with DVR enabled. DVR requires the stream name to begin with the mp4: prefix and end with the suffix.f4v, since the server writes the DVR copy in real time on the server side and requires a more specific filename. The prefix mp4: indicates to the server that the file contains H.264 video.
For example, your stream selection for "livestream" might be livestream500, livestream800, livestream1200, livestream1800, livestream2200, and livestream3000.
The DVR equivalent would be as follows: mp4:livestream500.f4v, mp4:livestream800.f4v, mp4:livestream1200.f4v, mp4:livestream1800.f4v, mp4:livestream2200.f4v, and mp4:livestream3000.f4v.
Follow these steps to set up Flash Media Live Encoder for dynamic streaming:
  1. Select Output from the Panel Options menu on the right side of the Encoding Options tabbed panel.
  2. Select Stream to Flash Media Server.
  3. Specify your Flash Media Server URL. For the stream name, you can use %b as a placeholder for the bit rates to differentiate the streams (see Figure 1).
  4. Specify the video streams and encoding properties. For this example, use H.264 as the video codec and MP3 as the audio codec.
Figure 1. Setting up the Flash Media Server URL and stream name in Flash Media Live Encoder
Multiple encoders
One challenge with multiple streams is that they eventually get out of sync because they are sent separately. Flash Media Server has built-in in functionality to synchronize incoming streams based on the source video time code. If you publish from the same encoder, your stream time codes should be in sync. If you run your encodes across multiple encoders, the encoders need to synchronize the time code. The implementation depends on the encoder. Flash Media Live Encoder uses the Network Time Protocol (NTP), while some third-party encoders support synchronization based on the source time code.
To enable NTP synchronization in Flash Media Live Encoder, turn on the feature in the <FMLE Installation Directory>/conf/config.xml file:
<streamsynchronization> <!-- "true" to enable this feature, "false" to disable --> <enable>true</enable> ... </streamsynchronization>


Installing and configuring Flash Media Interactive Server
To use the DVR functionality, you'll need to install Flash Media Interactive Server (or Flash Media Development Server) and the DVRCast application.
If you don't have a license for Flash Media Interactive Server, you can download and install Flash Media Development Server. It has the same functionality but it is limited to 10 concurrent users and is free to use. See the Beginner's guide to installing Flash Media Server 3.5 for detailed instructions.
DVRCast is a prebuilt, server-side application for Flash Media Interactive Server 3.5 that makes it easy to add network-based DVR functionality for small- to large-scale deployments (Origin/Edge architecture support).
After you download and unzip the DVRCast application ZIP file, copy the dvrcast_origin folder to your Flash Media Server applications folder.
Controlling the DVR
DVR recording does not start automatically on the server when the streams are available. There are several ways to start the recording and control other DVR functionality. One option is to use the DVR controls in Flash Media Live Encoder. If you are using a third-party live encoder, however, it might not offer the same control functionality. Since DVRCast provides an ActionScript-based interface, it is possible to simply trigger DVR through a Flex-based application.
DVRController is a small Flex-based application that you can use to start and stop DVR recording.
To install and run DVRController:
  1. Download and unzip the sample file,
  2. Locate the folder DVRController/web and copy its contents to your web server.
  3. Open DVRController.html in your browser and follow the on-screen instructions (see Figure 2).


Figure 2. The DVRController application
In you are a developer, you may be wondering what is going on behind the scenes. You can look at the source code and find additional information in the DVRCast documentation. One of the keys is a call to the server-side function, DVRSetStreamInfo. The application calls this function with a stream information object:"DVRSetStreamInfo", new Responder(onDVRSetStreamInfo),streamInfo);
The application is fully customizable and can be embedded into existing workflows. You can also publish the application as an Adobe AIR application and run it as a local application on the system running the encoder or server.
Using the video player
On the client side, you will need Flash Player 10 and a script with dynamic streaming capabilities. There are a couple of resources available for creating the client-side logic, including the FLVPlayback 2.5 component and the Open Source Media Framework. The player included in the sample file uses FLVPlayback 2.5, an ActionScript 3 component with full support for dynamic streaming and live DVR functionality.
There are two versions of the player in the sample file. The version in player/web/live supports dynamic streaming, and the version in player/web/livedvr supports live dynamic streaming with DVR functionality.


To set up the player:
  1. Copy the version you want to use to your web server.
  2. Edit the video.smil file to configure your streams:


<head> <meta base="rtmp://" /> </head> <body> <switch> <video src="mp4:livestream500.f4v" system-bitrate="500000"/> <video src="mp4:livestream800.f4v" system-bitrate="800000"/> <video src="mp4:livestream1200.f4v" system-bitrate="1200000"/> <video src="mp4:livestream1800.f4v" system-bitrate="1800000"/> <video src="mp4:livestream2200.f4v" system-bitrate="2200000"/> <video src="mp4:livestream3000.f4v" system-bitrate="3000000"/> </switch> </body> </smil>


The stream names should be identical to the publish names; for example mp4:livestream500.f4v for a live DVR stream or livestream500 for a live stream. Remember to replace rtmp:// with your own Flash Media Server URL and specify the correct bit rates in byte format.
  1. Save the video.smil file and open the index.html file in your browser to start the player. The player (see Figure 3) now streams your live content and adjusts the bit rate dynamically.
Figure 3. Live DVR player
This player is fully customizable, and the source is available in the sample ZIP file. It is optimized for 720p live streams and doesn't adjust the video object size for lower stream resolutions. If you host your video with a CDN, I encourage you to ask your CDN for a test player. Some CDNs require custom subscription logic for live streams, which is not part of the sample player.
Plans for the Open Source Media Framework include CDN-specific live support in the future. If you have any Flash development skills, you can also modify the source to add a subscription call.
Where to go from here
This tutorial covered the basic steps needed to set up your own dynamic streaming environment. If you are interested in more technical details, the Video Technology Center contains some useful and more detailed resources. Also refer to these specific articles:
Additionally, I recommend subscribing to the Flash Platform blog, which is great resource for staying up to date. Enjoy!