Dynamic streaming (Adaptive bitrate) using Flash media Server

Video and the web are long time friends already. You see lots of websites with some sot of player for video content.  Also, you can see media companies and television channels serving video over the wire to the end users.

Video can be downloaded (progressive download) to the client like YouTube or can be streamed to him.

I won’t discuss the pro’s & con’s of streaming and progressive. We’ll only be discussing streaming in this post.

So, What is the post worthy problem we have when streaming video to the client?

Continue reading and find out.

When streaming video, you usually encode your video in a certain bitrate. This bitrate will work well in certain computers and won’t work well in others. Why is that?

That’s because each of your users has a different connection thus being capable to receive a limited amount of bytes streamed to him. So, you always have to find the “sweet spot” where you deliver a video that looks good and also light enough to fit a wider range of network connection speeds.

That is of course a problem, becuase sometimes you want to stream hiQuality video and audio (HD) and you can’t, because some of your users won’t be able to watch it smoothly.

Well, this is a problem we will solve here in this post.

Flash media server introduced a new way of streaming video to the client. It’s called dynamic streaming and it is very dynamic (name implies just that).

That way, you can create several encodes to the same source movie and supply a movie best fit to the user cosuming it.

Another obvious advantage of this approach is the way it skips on top of the movie, when you skip to a further point in the movie, you are actually being supplied a different movie from the lowest quality to the highest.

So, how is it done, first, let’s create a flash file (I’m using flash CS4).

Now, we will create (by dragging and dropping from the components panel) an FLVPlayback control.

We will give it the same dimensions as the movie itself so it will fill the entire surface.

Now, we will give the player an instance name of “flvPlayer”

So, we have a movie, we have an FLVPlayback control, we called it “flvPlayer”.

We will create another layer, called “action script” and we will create this code inside.


import fl.video.*;

VideoPlayer.iNCManagerClass = NCManagerDynamicStream;

flvPlayer.source = “dynamicStream.smil”;


OK, so as we can see, we created a pointer to a file called “dynamicStream.smil”, this is a special file (XML format).

This file details the following:

The file looks like this:



Now, when we put this file on our web-server, the user will get the file it can receive and play, not slower, not faster, just the perfect file for him.

NO buffering, NO waiting, NO frustration, smooth, cool and fast user experience.

Good luck!

You can download the complete solution from here:

[download id=”3″]

Submit to Hacker News

[NOTE] This post has been imported to Hugo from a Wordpress blog. It may be broken, missing images, code snippets or other information.

[NOTE] updated April 15, 2010. It's 3210 days old . This article may have outdated content.