Dynamically created SMIL for VOD and Live Streams

We recently published an article outlining how to get some meta data from VOD files for use with the AMLST extension and although reasonably useful we have recently been furnished with a significantly better approach and decided to build a full solution to share.

When using adaptive bitrate streams , so multiple files or live streams, in accordance with the Wowza Streaming Engine a SMIL file needs to be created that outlines the file/stream names and the capabilities of each entry – so bitrate, codec etc.

For many deployments the naming scheme used for multiple bitrate files/streams falls under the following format

<stream/filename><bitrate>

An example for on demand stream would be

sample_700.mp4
sample_1100.mp4
sample_1500.mp4

An example for live streams would be

myStream_1
myStream_2

In both cases the sample or myStream part may change, but the _700,_1100,_1500 or _1,_2 would remain the same across other files. To this end we have designed a template which allows you to describe the entries that are expected but at a minimum level.

An example of the template is as follows

<RenditionList>
	<Rendition name="%s_1" />
	<Rendition name="%s_2" />
</RenditionList>

This template shows two entries, called Rendition, and their name is described as %s_1 or %s_2. The %s denotes the stream name used in the AMLST request and is substituted when the request is made.

We have made the template system also dynamic so you can describe one for general use called

amlst_template.xml

or one for specific stream name used called, where <stream name> is the AMLST stream name requested

<stream name>_template.xml

These should be placed in the StorageDir location as described in the Application.xml for the application in used, commonly content/ in your Wowza Streaming Engine installation.

The stream name specific one is looked for first and if not found then the generic one is looked for. If neither are found an error is returned.

An example here is

http://192.168.1.50:1935/live/amlst:myStream/playlist.m3u8

This would look for a template called myStream_template.xml, if not found then look for amlst_template.xml in the StorageDir of the Application live.

When the template has been found and depending on the type of application in use, live or on demand, then the files/streams being requested have their information pulled together and pushed into the AMLST output.

Using the above references the request would look for two streams

myStream_1 and myStream_2

The two streams have the following characteristics from the encoder

myStream_1 – 640×300,1Mbps Video – 96Kbps – MP3 Audio
myStream_2 – 320×200,500Kbps Video – 96Kbp – MP3 Audio

The resulting output when doing the AMLST request for Apple HLS (Cupertino would be)

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1122304,CODECS="avc1.66.31,mp4a.40.2",RESOLUTION=640x400
chunklist_w1868630013_b1122304.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=610304,CODECS="avc1.66.31,mp4a.40.2",RESOLUTION=320x200
chunklist_w1868630013_b610304.m3u8

The template system also allows other attributes to be added per rendition and these are

language
type
name
groupname

These can be applied as follows

<RenditionList>
	<Rendition name="%s_1" language="en" />
	<Rendition name="%s_2" type="audioonly" />
</RenditionList>

This would produce a Apple HLS output of

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1122304,CODECS="avc1.66.31,mp4a.40.2",RESOLUTION=640x400
chunklist_w128793496_b1122304_slen.m3u8
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="default",NAME="myStream_2",URI="chunklist_w128793496_b610304.m3u8"

You should notice the ‘GROUP-ID’ has been set to ‘default’ which is the case if no groupname is specified.

To use the module with this functionality add the following Module entry as the last Module in the Modules list within your Application.xml

<Module>
	<Name>Test</Name>
	<Description>Test</Description>
	<Class>guru.thewowza.example.dynamic.SMIL</Class>
</Module>

It does of course work with other HTTP Streaming protocols as it is using the AMLST extension. You do need to copy the template files into the StorageDir of the application you are using and edit them as needed.

They can be downloaded here, along with the source and compiled jar file.


Comments are closed.