Posts

Category: Flash Media Server

I made a few changes to this custom pod. You can register to download at the bottom of this article. The new file will be called fp10VideoPlayer.zip. Some of the changes were simple bug fixes for instance there was a problem accessing a stream with an mp4 extension and prefix, that is now fixed. That means that you should be able to use this with a CDN such as Akamai. Another highly requested feature was the ability to resize the video, that should now be possible. I have not done a lot of testing so use at your own risk.

In this article I will describe how to use a recently created custom pod for Adobe Connect. This custom pod is provided free of change and is provided as is with no additional support or warranty (how is that for some lawyer speak). Briefly, this custom pod allows you to stream high frame rate video from the Adobe Flash Media Server to an Adobe Connect meeting room. I used the collaboration sdk to create a shared experience. In other words if you are a host in a meeting room you can load and setup a connection to both live and ondemand video that you control for the meeting participants. As the host you make the connection and choose the video and when you hit play all participants will see that the video has started to play. This is very different than a typical video player where each individual has their own experience and could be watching different sections of a the same or different videos. This custom pod understands the different Adobe Connect meeting roles (i.e. host, presenter, participant). Only the host has interface elements (buttons, progressbar, etc…). Admittedly the user interface could use some work and I do intend to improve it so do not beat me up too bad but also do not hesitate to give me advice on improvements.

There are many considerations when ever you consider streaming high quality video. First of all the camera is an important part of the equation. I did a number of tests with web cameras and found that two of the three web cameras that I tested could not consistently produce 30 frames per second of video. Do not skimp on a quality camera. The second, third and fourth and and and considerations are all BANDWIDTH. You cannot stream a 500 kbps stream over a connection that only has 300 kbps available. There are many people that are confused about bandwidth but it is fairly simple. If you look at the diagram above you will notice that you have to send the encoded stream from the camera / laptop to the Flash Media Server and then on to Adobe Connect. You need the appropriate amount of bandwidth at each step. It is not enough to have a great connection from FMS (Flash Media Server) to Adobe Connect you also need an appropriate connection from the source (camera / laptop) to FMS. Often someone assumes that because their wireless card mentioned 54 Mbps that they are covered for streaming video. The key consideration is “usable bandwidth”. I have included the ability to test bandwidth in this application as well as a status indicator that will give you an idea if your connection is appropriate for the video you are attempting to stream. It is also important to note that available bandwidth changes continuously. You might find that you do a bandwidth test and have plenty and thirty seconds later you have half as much. It is best not to use a wireless connection as their is more variability and more unknowns with a wireless connection versus a wired connection.

Custom Pod UI:

Lets walk through some of the functionality of the custom pod. After it is uploaded to a share pod inside of Adobe Connect it should look like the following:

Adobe Connect Custom Video Pod

The first thing you should understand is that this is the interface that the host will see when they upload the custom pod. The dark green in the progress bar shows the progress of the playing video. The dark blue shows the size of the current buffer. If you do not see any dark blue then there is no buffer and you are probably not having a great play back experience. You will not see a progress bar for live video as there is not enough buffer to show. Notice the green status indicator in the upper left hand corner of the screen. This indicator will be seen by both hosts presenters and participants. This indicator shows only the local connection status. In other words if you are looking at this indicator it shows your status not a combined or status of other individuals in the meeting. The following table gives a brief highlight of the states and meanings.

This indicates no connection. Each time you connect the indicator will turn green initially and each time you disconnect it will turn black.

This indicates the initial connection as well as a video that has enough bandwidth to play and keep up with the video that is being sent from the Flash Media Server.

This indicates that there are or have been issues with the video playback. Often times this is represents a temporary condition so do not panic the first time you see the indicator turn orange or red.

This indicates that the issues are getting worse but as stated before this can be temporary so give it at least a few seconds and see if the condition improves.

If someone in the meeting mentions that the video playback is not smooth or the quality is not great you could ask them what the color of the indicator is to get an idea if the problem is bandwidth related. This indicator does not indicate a change in frames per second. It is possible to retrieve fps data from the metadata of the stream but it seems that this does not indicate that actual fps on the passed on from the encoder (e.g. Flash Media Live Encoder).

Adobe Connect Meeting Host:

You will notice that each role in an Adobe Connect meeting has a slightly different view of this custom pod. The host has complete control. As a mater of fact the first host to upload the custom pod retains complete control and all other hosts will see the controls but will only be controlling their local experience. With that said I think that it is a good practice to have only a single host in most if not all meetings. More than one presenter is not an issue but more that one host can create issues regardless if you are using this custom pod or not. The following is the host view of the custom pod:

Custom Pod with Settings Visible

Workflow for live video:

The first step to playing live video is to have a live video source. Keep in mind that if you intend to use a simple web camera your quality will probably not be that much better than what you would get out of the default camera support in Adobe Connect. If on the other hand you have a higher quality camera or would like a higher frame rate follow these steps.

1) setup a computer with enough horse power to encode the video and with enough bandwidth to send that video to the Flash Media Server. Download and install the free Flash Media Live Encoder.

2) setup or use an existing Flash Media Server. There are a great number of resources for getting started with the Flash Media Server.

3) upload the custom pod. The custom pod is in a zip archive. In a share pod in Adobe Connect simply locate the custom pod zip archive on your computer and upload the entire zip.

4) enter the server url and stream name for the video that you are publishing from the Flash Media Live Encoder. It is a simple matter to find the connection stream for the server. You will notice by the example above the entry field that it starts with rtmp. This is the realtime message protocol used by FMS. The next element in the connection stream is the server ip address or dns name. After the slash following the server name or ip address is the application name. This may seem a little strange but this represents a folder name inside the application folder inside the installation folder of the Flash Media Server. Once you have the Flash Media Server installed find the installation folder and open it and inside you will find the application folder. Inside of the application folder you will find a vod and live directory. These are the default applications. If we analyze the following connection url, rtmp is the protocol, the ip address is the address of the Flash Media Server and vod represents the default directory for ondemand streams (i.e. files) inside the application directory.

rtmp://192.168.0.2/vod

The stream name is what ever the file name is for ondemand or what ever name you entered into the Flash Media Live Encoder.

Flash Media Encoder Output Panel

After the all the elements of the workflow are in place it is time to turn on the camera and stream the video from Flash Media Live Encoder to FMS. This is a pretty straight forward task, simply hit the start button in Flash Media Live Encoder.

Once the live video is streaming to Flash Media Server it is time to connect to and play the live stream into the custom pod inside of Adobe Connect.

Custom Pod Settings Panel

This is the settings panel for the Custom Pod that you will use in the Adobe Connect Meeting room. It allows you to setup and make a connection to the Flash Media Server. It also allows you to choose between ondemand and live streams and test your bandwidth. Notice that the stream name is the same as the the stream field in the Flash Media Live Encoder. If these do not match you will not see video in the custom pod.Also notice that if you want to view live video you must select the Live Stream check box.

Well I think that about covers it. I will post the link to down load the custom pod later today along with a few other links that might be helpful. Please drop me a comment to let me know if it is working or not and any improvements that you would like to see.

I put together a short overview presentation of the custom pod functionality and setup. If you would like to jump right to the link that allows you to register for download it is on slide eight. Please let me know what you think. Note: If you are having trouble with the registration page clear the cache on your browser and reload the page.

In case you missed it Adobe announced Flash Media Server 4 . This is a significant release for a number of reasons. The first reason is that many corporate customers have been interested in Flash video but were not able to take advantage of it with out support for IP Multicast as this technology was a mandate from their IT organization. In other words this update for the Flash Media Server to version four gets you a 64bit architecture, Absolute timecode, faster seeking, trick mode playback (fast motion, slow motion, and frame stepping), intelligent reconnect, faster switching for RTMP Dynamic Streaming and IP Multicast Support.

Using version 4 of the interactive edition of the Flash Media Server gets you the ability to choose between Unicast (with or with out Origin / Edge), IP Multicast and even Live HTTP Dynamic Streaming. It is even possible to failover from IP Multicast to a Unicast stream if necessary. When you consider all of the possibilities they include:

Interactive applications that support video, audio and data for one to many and many to many for both live and video on demand

Large scale broadcasts using IP Multicast

Origin / Edge solutions that can be used to intelligently reduce bandwidth requirements for vod

That is a short summary of the possibilities that you get with the interactive edition of the Flash Media Server but that was not the only announcement. Adobe also announced Adobe® Flash® Media Enterprise Server 4. If you are not familiar with RTMFP that would be a good place to start. This peer protocol will allow you to take advantage of users / viewers upstream bandwidth to broadcast video, audio and data in your application and now the Flash® Media Enterprise Server 4 can participate in those groups. So consider the limitations of a peer broadcast. First you will only have access to the one video codec that can encode that is part of the Flash Player and that is Sorenson Spark. If you are familiar with Sorenson Spark you know that the quality leaves something to be desired. When you consider that theFlash® Media Enterprise Server 4 can act as a peer using RTMFP you now have access to all of the varied video formats that can be broadcast using the server (On2, H.264,…). It is also important to note that you are not limited to just video when you are using Peer Assisted Multicast (RTMFP) you can include data as well. These applications can include interactivity unlike IP Multicast. Of course there are considerations that include additional latency based on the number and location of peers in a group but the possibilities are amazing. Just consider an internet based application that includes video and interactivity with 10k concurrent users. With out a peer solution you would have to invest in a significant number of servers as well as a significant amount of bandwidth. With the Flash® Media Enterprise Server 4 you could address both server and bandwidth requirements with a small fraction of what it would take with a Unicast solution. The cost savings will be significant.

After numerous calls to help people confirm that the server was working correctly I decided to write a media player that would help test and confirm the ability to stream video from the Flash Media Server. This player is provided as is with no warranty or support but I hope you will find it useful. This is an AIR based player. I created it for AIR for a number of reasons not the least of which that it was easy to install and run locally with out the need for an http server. I have already thought of a few additions so let me know if you find it useful. It is simple to use, just enter the url to some media on an FMS server in the following form:

URL Syntax: rtmp://[servername]/[application]/[streamname+extension]

1) [servername]: this is the IP Address, or the domain name of your server. (i.e. localhost)
2) [application]: use “vod” unless you have created a new directory in the application folder of the Flash Media Server installation directory. There are two built in applications vod and live.
4) [streamname]: use the name of your video file (including the extension). The extension can be flv, f4v or mp4. You do not need to prefix the file name with the content type (e.g. mp4:).

Overview:
This will most likely turn into a series but I had to start some where. In this article I am going to cover a topic that comes up regularly, configuring the Flash Media Server to support multiple networks with different bandwidth capabilities. To be more clear imagine a central data center with the Flash Media Server installed and multiple remote locations with constrained bandwidth connections to the data center. How do you limit the amount of bandwidth consumed by one location with out limiting every other location?

The first thing to be aware of is that the Flash Media Server is very configurable. With a single server installation you can serve multiple networks with multiple virtual hosts that each have their own configuration. These configurations are handled by editing xml configuration files and creating directories in the conf directory of the Flash Media Server installation folder. For this article I am going to focus on creating a virtual host for each remote site and assume that we do not need multiple adapters. The configuration guide gives the following guidance regarding virtual hosts and adaptors:

“You can assign an IP address or a port number to an adaptor, but not to a virtual host. For this reason, use adaptors to organize virtual hosts by IP address or port number. For example, if a virtual host needs its own IP address to configure SSL, assign it to its own adaptor.”

Getting Started:
The process of creating a virtual host is fairly easy. First you locate the conf directory in the Flash Media Server installation directory. Then create a folder with the name of the virtual host inside conf/_defaultRoot_/. This name is important as it will be the name you use to create a DNS entry. A DNS entry is required so that all requests coming to the server with that name are directed to the appropriate virtual host. If you are setting up a development environment (this will not work in production) you can use a the host file to map the virtual host name (e.g. http://www.first.com) to the local ip address (e.g. 127.0.0.1). In my host file I have the following entry:

If I had two virtual hosts setup (www.first.com and http://www.second.com) the DNS entry is used to direct the requests to the appropriate virtual host even though they are on the same server with a single instance of the Flash Media Server installed. To elaborate that would mean that I would have two folders in the conf/_defaultRoot_/ directory the first would be http://www.first.com and the second would be http://www.second.com.

Flash Media Server Install Directory and vhost folders

Once the folders are created you will copy the Application.xml and the vhost.xml file from conf\_defaultRoot_\_defaultVHost_ and paste copies into both the http://www.first.com folder and the http://www.second.com folder. The Users.xml file is required only if you are defining administrators for this virtual host. Finally you will specify the location of the application directory for each virtual host in the vhost.xml file. This is required to avoid namespace conflicts. The application directory will hold the server side script and optionally content if you want different content for each virtual host. You can think of the application directory that you just created as being synonymous with the vod and live directory in the top level of the application folder in the Flash Media Server installation folder. The entry in the vhost.xml file to setup an application directory (you have to do this for each virtual host) should look something like the following:

<AppsDir>C:\myvhostApplications\first</AppsDir>

Notice that I do not have to use the name of the vhost folder (www.first.com) this is simply the location where we will store server side script and or content. For the sake of completeness, for the vhost.xml file in the http://www.second.com folder inside conf/_defaultRoot_/ you would have an entry similar to the following:

<AppsDir>C:\myvhostApplications\second</AppsDir>

The applications directory is the base directory where all applications for this virtual host is defined. You can store the video files in these directories but since the goal of this article is to show how to limit bandwidth it is assumed that each location would want access to the same content. If that was not the case you could simply create a sub folder streams and an other folder called _defInst (default instance) for each of the following and put the content for that virtual host inside that directory.

C:\myvhostApplications\first

C:\myvhostApplications\second

vhost application and content directories

The goal of this example is to serve multiple vhosts which will serve multiple locations with varying bandwidth limits with the same content available for each virtual host. We will use the settings in the vhost.xml file to limit the number of streams available for each virtual host.

In order to limit the total number of connections from a given location to a virtual host on the Flash Media Server we will use the MaxConnections setting found in the vhost.xml file of each virtual host. In other words inside the http://www.first.com folder inside conf\_defaultRoot_ you will find the vhost.xml file with the MaxConnections setting.

<MaxConnections>-1</MaxConnections>

By default it is set to -1 which means unlimited. You can set this to what ever number makes sense for your circumstance.

It will also be a good idea to disconnect idle viewers so that after a specified idle time some else can view content. This is also handled in the vhost.xml file for each virtual host with the following setting where the MaxIdleTime is the maximum idle time allowed, in seconds, before a client is disconnected.

It turns out that there is a hidden configuration that sets the amount of time that the server waits to check the configuration. The value is in seconds, and 60 is the default. Together these two numbers represent the amount of time before an idle user is disconnected.

Example:|
As an example assume that you have a number of remote locations with 500 kbps of available bandwidth and you want to make sure that no more than 500 kbps of content are served across that connection at any time. By setting up virtual hosts for each remote location you can set a MaxConnections limit for each virtual host that would limit the number of people that could watch video from that location at any given time. The next step is to make sure that you encode your content to fit with in that limit. This is not the article to talk about encoding but for the purpose of clarity, I would follow the following guideline. Make sure that you use constant bitrate encoding (CBR) not variable bitrate encoding (VBR) and make sure that the total bitrate is less than the available bandwidth (500 kbps). As an example if I had 500 kbps I might encode my video at 350 kbps and my audio at 90 kbps and that would give me a total of 440 kbps.

Finishing the Configuration:

Now that the virtual host is setup and the content is encoded lets add an entry to each vhost.xml file so that they can have access to the same content. I should point out again that you could simply have copies of content in each virtual host application directory specified by the <AppsDir> setting but if the content is that same that is needlessly using drive space. A better approach would be to have a single directory of content that is shared between virtual hosts. You can do this with a setting in each vhost.xml file called <Streams> in side the <VirtualDirectory> tag. I used the following setting that tells each virtual host with this setting in the vhost.xml file to look in the C:\vhostContent directory for content.

<Streams>/;C:\myvhostContent</Streams>

With this setting there is no need for subfolders you can simply put your video files in the myvhostContent directory.

This setting can be used to group virtual hosts. Remember that the process of limiting bandwidth is based on two criteria. First limiting the number of connections using MaxConnections in the vhost.xml file. Second encoding your content to a specific bitrate that does not over run your available bandwidth. In the example in this article I used 500 kbps of available bandwidth and encoded the content to a total of 440 kbps. If you had groups of remote locations that were similar, for instance lets say that you had four locations that had t1 (1.54Mbps) connections and four locations that had with OC3 (155 Mbps) connections depending on the available bandwidth for each group you would want two sets of content. In this scenario you would have eight virtual hosts. You would edit the vhost.xml file for each virtual host and point it at a one of two content directories using the <Streams> setting mentioned earlier. In this way you would only have two copies of the content but they would be encoded at different bitrates. For the t1 connections I might encode my content to be under 300 kbps and for the OC3 connection I might encode my content to be 900 kbps or even use Dynamic Streaming to get the most out of the content and connection.

Playing the Content:
So now that we have everything setup how do you play the content. Just to keep things simple lets use Flash CS5. Make sure that you have the newest Flvplayback (version 2.5) component, you can download it from here. Create a new file (file > new > actionscript 3) then drag the FlvPlayback 2.5 component out onto the stage (save the file). In the property inspector open the source property and enter the protocol (rtmp://) then the name of the folder that represents the name of the vhost (www.first.com) then the application name. The application name is the name of a folder inside the application directory. Remember that the application directoryis what we specified in the AppsDir setting of the vhost.xml file.

<AppsDir>C:\myvhostApplications\first</AppsDir>

If we consider the preceding setting in the vhost.xml file the application name would be a folder inside the folder with the name first. Lets refer to the application name as simpleAppand lets assume that the video we are going to play is myvideo.flv. That would mean that the source property for the FlvPlayback component would be:

rtmp://www.first.com/simpleApp/myvideo.flv

Summary:
Lets review what we have done. First we created a folder (www.first.com) that represents a virtual host in the conf\_defaultRoot_ directory of the Flash Media Server installation directory. This name is mapped to the machine IP adddress with a DNS entry for production or a hosts file for a development environment. We copied the vhost.xml and application.xml file into that folder (www.first.com) from the conf\_defaultRoot_\_defaultVHost_ folder of the FMS installation folder. We added an entry to the <AppsDir> setting in the vhost.xml file as well as the <MaxConnections>- setting. The <AppsDir> sets up an application directory for the virtual host and the MaxConnections setting limits the number of connections coming into that specific virtual host. Then you encoded your content to fit within the bandwidth limits required for that virtual host and finally we added an entry to the <Streams> so that groups of virtual hosts could have access to the same content without having to copy the same content into every virtual host application directory. Finally you will have to create different Flash / Flex applications or pass in variables so that each location uses the correct connection string (rtmp://{virtualhost}/{application}.{video}). Check out an article that I wrote regarding how to pass variables into Flash using the query string.