HTTP Dynamic Streaming & Live Events

Flash Media Server (FMS) allows for the streaming of live video over HTTP. The following is a list of concepts that apply to HTTP Dynamic Streaming & live streams:
  • To stream live video over HTTP, the FMS uses the concept of live events.
  • A live event is configured as part of a FMS application.
  • An application configured for live events and can have multiple events.
  • As with normal FMS applications the name of the directory is the name of the event.
  • Live events can be configured for multi-bitrate streaming.
  • The streams are packaged as fragments and written to disk on the fly. Meaning a player can access the content after the live stream has stopped.
  • Live events support DVR and DRM.

Creating a live event

The steps involved in creating a live event are very similar to creating a normal FMS application with the addition of the Event.xml file. They are:

  1. Create the FMS application {FMS_INSTALL}/applications/{APPLICATION_NAME}
  2. In the application directory create the following directory sturcture: events/_defInst_/{EVENT_NAME}
  3. Create an Event.xml file in the ‘events/_defInst_/{EVENT_NAME}’ directory and at a minimum specify the fragment & segment duration:[xml]<EventID>{EVENT_NAME}</EventID>
    <Recording>
    <FragmentDuration>4000</FragmentDuration>
    <SegmentDuration>10000</SegmentDuration>
    </Recording>[/xml]

When you install the Flash Media Server a preconfigured live event is installed as well. The application is called ‘livepkgr’ with a live event called ‘liveevent’. The configuration exists in ‘{FMS_INSTALL}/applications/livepkgr/events/_defInst_/liveevent’

Packaging for Live Events

The Event.xml contains the configuration information for the live event. This includes:

  • Segment and fragment settings
  • Content protection (Flash Access) information

A sample Event.xml file with segment/fragment settings as well as content protection configuration:

[xml]
<Event>
<EventID>liveevent</EventID>
<Recording>
<FragmentDuration>4000</FragmentDuration>
<SegmentDuration>10000</SegmentDuration>
<ContentProtection enabled="true">
<ProtectionScheme>FlashAccessV2</ProtectionScheme>
<FlashAccessV2>
<ContentID>foo</ContentID>
<CommonKeyFile>common-key.bin</CommonKeyFile>
<LicenseServerURL>http://dill.corp.adobe.com:8090</LicenseServerURL>
<TransportCertFile>production_transport.der</TransportCertFile>
<LicenseServerCertFile>license_server.der</LicenseServerCertFile>
<PackagerCredentialFile>production_packager.pfx</PackagerCredentialFile>
<PackagerCredentialPassword>hbXX5omIhzI=</PackagerCredentialPassword>
<PolicyFile>policy01.pol</PolicyFile>
</FlashAccessV2>
<ContentProtection>
</Recording>
</Event>[/xml]

The parts to pay attention to in the file Event.xml file above are:

  • SegmentDuration: The length of the segments in milliseconds. Each F4F file contains one segment.
  • FragmentDuration: The length of the fragments in milliseconds. Each segment can contain multiple fragments.
  • ContentProtection: Specifies if the content is protected as well as the details necessary for Flash Access content protection.

DVR & Multi-bitrate Live Events

To create a DVR or multi-bitrate (MBR) live event you will also need to create a Manifest.xml file in the live event folder (events/_defInst_/{EVENT_NAME}/Manifest.xml). This file will contain the DVR and MBR settings for the live event. Sample Manifest.xml file:

[xml]<manifest xmlns="http://ns.adobe.com/f4m/1.0">
<dvrInfo beginOffset="0" endOffset="0"></dvrInfo>
<media streamId="livestream1" bitrate="100" />
<media streamId="livestream2" bitrate="200" />
<media streamId="livestream3" bitrate="350" />
</manifest>[/xml]

The <dvrInfo> node:

The <dvrInfo> node contains 2 attributes and controls the DVR functionality for the live event:

  • beginOffset: The value (in seconds) is where the client players will begin viewing the stream. The default is 0 & negative values are treated as 0.
  • endOffset: This value in seconds specifies how many seconds behind the current duration of the stream clients can view. The default is 0 & negative values are treated as 0.

Do not include this node if you do not want to use DVR functionality.

The <media> node:

Thenodes are used to specify the multi-bitrate (MBR) settings for the live event. The file is parsed and used by FMS to create the streams for the live event based on the settings specified in the media nodes. The manifest file is then updated with the nodes and data necessary (id, duration, bootstrap and metadata) for a client player to play the stream. The initial file should contain the following attributes for eachnode:

  • streamId: The name of the publishing stream
  • bitrate: The bitrate the stream was encoded at

If you do not want to use MBR do not include the media node(s).

Playing Back Live Events

Setting up an FMS application to publish a live event is as simple as creating the application (directory), and the Event.xml file. Of course adding MBR, DVR and content protection will add to the setup and configuration, but it is still a pretty straight forward process. Once the FMS application is configured we’ll need to do a couple of things:

  1. Publish a stream to the application and associate the stream with the live event
  2. Play back the stream in a player. We’ll use the Flash Media Playback to keep things simple.

Publish a Stream and Associate it with a Live Event

To publish a stream we’ll use the Flash Media Live Encoder. We’ll also need to associate the stream to the live event. This will be accomplished with a main.asc file and a bit of server side code. First we’ll cover the server side code, then we’ll set up the Flash Media Live Encoder.

Associating a Stream with a Live Event

I used the main.asc found in the ‘livepkgr’ application installed with Flash Media Server as a base (I’ve change a couple of things). You can download the main.asc I use here. The main.asc file just needs to go in the application directory ({FMS_INSTALL}/applications/{APPLICATION_NAME}). A little explanation of what is going on in the main.asc: The stream is associated to the live event in the onPublish() method (ln. 60 in main.asc):

[as3]s.liveEvent = liveEventName;[/as3]

The variable ‘liveEventName’ is set to the stream name (default):

[as3]if( nv.localeCompare( "event" ) == 0 )
{
liveEventName = nval;
break;
}[/as3]

or to the value passed in as the URL variable ‘event’ (ln. 34 – 44 in main.asc).

[as3]var nvpairs = new LoadVars();
nvpairs.decode(queryString);
for( var nv in nvpairs )
{
var nval = nvpairs[nv];
if( nv.localeCompare( "event" ) == 0 )
{
liveEventName = nval;
break;
}
}[/as3]

Now to publish the stream.

Publishing the Stream Using Flash Media Live Encoder

To publish the stream we’ll need to connect to the FMS application and then pass the name of the event that we want to stream to. This is accomplished by adding URL variables to the stream name. For example: Live event publish settings Make sure to replace {APPLICATION_NAME} with the actual name of your live event application and {EVENT_NAME} with the actual name of your event. You will also need to make sure you are using H.264 and set up any MBR streams: Live event publish settings 2Click the start button, and the stream should start publishing to your FMS server.

Playing Back the Live Event

To play back the stream, we’ll use the Flash Media Playback. So go to http://osmf.org/configurator/fmpto setup the player.

  1. Set the ‘Video Source’ to: http://{FMS_SERVER}:{FMS_HTTP_PORT}/live/events/{APPLICATION_NAME}/events/_defInst_/{EVENT_NAME}.f4m
    • For FMS 4.5 the path will be http://{FMS_SERVER}:{FMS_HTTP_PORT}/hds-live/{APPLICATION_NAME}/{INSTANCE_NAME}/{EVENT_NAME}/{STREAM_NAME}.f4m
  2. Select Yes for ‘Are you using HTTP Sstreaming or Flash Access 2.0?’
  3. Remove the value for ‘Poster frame file location’
  4. Select Yes for ‘Autoplay Content’
  5. Click the ‘Preview’ button.

The live event should start playing: Hds live event playbackThere you go – live Events streamed over HTTP that supports multi-bitrate, DVR & content protection using Flash Access. In the next few articles I’ll dive into Flash Access and what is required to get your content protected and secured. Resources:

  • Flash Media Server Developer’s Guide: http://help.adobe.com/en_US/flashmediaserver/devguide/WSd391de4d9c7bd609-52e437a812a3725dfa0-8000.html
Comments
  1. Fei Huang
    • jccrosby
  2. James
  3. M Corona

Leave a Reply

Your email address will not be published. Required fields are marked *