Cleaning Up After Adobe Media Server Live HDS Events

After broadcasting a live event using using Adobe Media Server (AMS 5) you’re left with a bunch of files (.control, .meta, .bootstrap, .f4f .f4x). When you start the live event back up, things can get wonky and you won’t be able to use that live event again. This can be problematic if you have a regular live event that you want to broadcast and don’t feel like setting up a live event or don’t want to have a bunch of live events hanging around on your server all the time.

Telling AMS to Clean Up

There is an easy solution – you can tell AMS to clean up after it’s self when the application is terminated. Meaning that the files that are deposited in the /streams directory are removed and ready for another live event. This saves space on your server and it saves you the headache of having to manually clean up the files.

The Clean-up Command

To get AMS to clean up the live event files, add the following directive to the application’s Application.xml file:


After you restart the application, broadcast a live event, then stop the live event and then unload the application, you should see that the files have been cleared from the stream directory.

NOTE: You can add this directive to the server level Application.xml, but I would suggest keeping it on the application level.

Configuring AMS for Real

For a default install of AMS using the “livepkgr” application, open the Application.xml file in the {AMS_INSTALL}/applications/livepkgr directory.

Add the following xml as a child of the <application> node:


Save and close the file.

Do a little live streaming and notice the files being created in the {AMS_INSTALL}/applications/livepkgr/streams/_definst_/livestream directory.

Before Clean Up

Stop broadcasting your live stream and either wait for the livepkgr application to unload or use the admin concole to unload the application. As soon as the application is unloaded, the livestream directory should be removed from {AMS_INSTALL}/applications/livepkgr/streams/_definst_ effectivley cleaning up your server for you.

Clean Up After

I thought this was a nice little find, what do you think?

Let me know in the comments.

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>

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:

<ContentProtection enabled="true">

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="">
<dvrInfo beginOffset="0" endOffset="0"></dvrInfo>
<media streamId="livestream1" bitrate="100" />
<media streamId="livestream2" bitrate="200" />
<media streamId="livestream3" bitrate="350" />

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;

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

[as3]var nvpairs = new LoadVars();
for( var nv in nvpairs )
var nval = nvpairs[nv];
if( nv.localeCompare( "event" ) == 0 )
liveEventName = nval;

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 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: