Multi Bitrate Live Streaming with FMLE ( Adobe Flash Media Live Encoder )

Posted by Kristofer Joseph Thu, 28 May 2009 21:02:53 GMT

How to connect to a multi bitrate encoded live stream from Adobe Flash Media Live Encoder. What follows is the easiest way to connect to a multi bitrate live stream produced from FMLE 3.0 and played back through the FLVPlayback 2.50015 component along with some tips I picked up while trouble shooting.

What you will need:

This post assumes you have all of these installed properly and you are able to connect to a single stream without issue. For information on getting started with any of these refer to their accompanying documentation. More info can be found at the Adobe Developer Connection FMS resources page including some tutorials to get you started. Any issues you find that are not covered in this post should be referred to the forums.

*Disclaimer: I am using Edgecast as my CDN. They make it very easy to find all of the info needed. Different CDN’s may vary. Things you will need to know that will be specific to your CDN are:

  • how to enable an authentication token
  • how to add your authentication token to your stream name in FMLE
  • What version of FMS they are running ( You will need 3.5 )

Steps to playback a Live multi bitrate encoded stream:

in Adobe Flash Media Live Encoder set two things:

First

 FMS URL: rtmp://server_path/application_name

*Tip: my cdn network supplied the path to use but added a trailing forward slash to the rtmp path after the application name. This is wrong. Once I removed the trailing froward slash the streams started working.

Example: 
They supplied rtmp://server_path/application_name/
Needed to be rtmp://server_path/application_name

Second

Stream: stream_name%i/auth_token

*Tip: streamname can be whatever your heart desires, it just needs to match what you put in your video player’s connection code. the %i is just a dynamic iterator so depending on how many streams you have set up it will translate to streamname1, streamname2, streamname3 if you had set up three different encoding rates. Also auth_token is only needed if you have set it up to need authentication. If you are running this locally you will not need to worry about it. Some CDN’s set this up automagically for you though.

You will see the names created in the encoding log like so:

Thu May 28 2009 12:45:59 : Primary - Connected
Thu May 28 2009 12:46:13 : Primary - Stream[livestream1/auth] Status: Success
Thu May 28 2009 12:46:13 : Primary - Network Command: onFCPublish
Thu May 28 2009 12:46:13 : Primary - Stream[livestream1/auth] Status: NetStream.Publish.Start
Thu May 28 2009 12:46:13 : Primary - Stream[livestream2/auth] Status: Success
Thu May 28 2009 12:46:13 : Primary - Network Command: onFCPublish
Thu May 28 2009 12:46:13 : Primary - Stream[livestream2/auth] Status: NetStream.Publish.Start
Thu May 28 2009 12:46:13 : Primary - Stream[livestream3/auth] Status: Success
Thu May 28 2009 12:46:13 : Primary - Network Command: onFCPublish
Thu May 28 2009 12:46:13 : Primary - Stream[livestream3/auth] Status: NetStream.Publish.Start
Thu May 28 2009 12:46:13 : Session Started

These are the names you use in your DynamicStreamItem addStream method call.

Example: 
addStream(streamname1,200)
where streamname1 is whatever is before the slash in the logs Stream[livestream1/auth] and 200 is the bitrate you chose for the stream. In my case the bitrate just had to be close, not exact.

in your desired Actionscript development environment attach to the stream:

Create your FLVPlayback component

vid = new FLVPlayback();
vid.autoPlay = true;
vid.isLive = true;

Create your DynamicStreamItem

var dynamicStream:DynamicStreamItem = new DynamicStreamItem()
dynamicStream.startRate = 200;

*Tip: the start attribute set to -1 states that you are playing a live stream. This is the set by vid.isLive = true;. A Gotcha you will undoubtably stumble on is you need to switch vid.isLive to false in order to play a non live stream. I can’t tell you how many times this has bitten me in the ass. Also remember to set your startRate property as low as you can and allow the stream to go up from there.

Set the path to your stream

dynamicStream.uri = "rtmp://your_rtmp_path/your_application_name";

*Tip: this will almost always be a different rtmp path than the one you broadcast to. You will need to check with your CDN to determine what this rtmp path should be.

Add your streams

dynamicStream.addStream("livestream1",200);
dynamicStream.addStream("livestream2",400);
dynamicStream.addStream("livestream2",600);

*Tip: notice how the stream name is the same as the one in the log from FMLE minus the forward slash and the auth token.

Call the new play2() method of the dynamic stream class and pass it your configured dynamic stream item.

vid.play2(dynamicStream);

Viola! You are streaming a multi bitrate encoded live stream.

*Tip: remember to add your video player to the display list.

3 comments | atom

Comments

Leave a response

  1. Sancho
    15 days later:

    How can i get FMLE for http://play.md ?

  2. Sancho
    15 days later:

    How can i find (get) FMS URL: for http://play.md ? Help pls ….

  3. Daniel
    9 months later:

    Hi,

    this example does not work for me. I got a lot of debugging errors (1120 1180 and 1119). Maybe someone can help me?

    Daniel

Leave a comment