How to specify a play start time and duration for HTTP streaming

You can play part of an on-demand file when streaming using the HTTP streaming protocols (Adobe HDS, Apple HLS, MPEG-DASH, and Microsoft Smooth Streaming). This article describes different methods for specifying the start time and duration.

Note: Works with Wowza Streaming Engine™ software and Wowza Media Server™ software.

Contents

Specify start time and duration in URL query parameters
Specify start time and duration in SMIL files
Specify start time and duration by using the server-side API
Specify start time and duration by using the MediaList API

Specify start time and duration in URL query parameters

All HTTP streaming protocols support the wowzaplaystart and wowzaplayduration query parameters. The time values are specified in milliseconds. The following examples show how to use these query parameters in URLs to play the sample.mp4 video file in your Wowza media server installation, starting at 30 seconds for a duration of 40 seconds.

Adobe HDS

 
http://[wowza-ip-address]:1935/vod/mp4:sample.mp4/manifest.f4m?wowzaplaystart=30000&wowzaplayduration=40000

Apple HLS

 
http://[wowza-ip-address]:1935/vod/mp4:sample.mp4/playlist.m3u8?wowzaplaystart=30000&wowzaplayduration=40000

MPEG-DASH

 
http://[wowza-ip-address]:1935/vod/mp4:sample.mp4/manifest.mpd?wowzaplaystart=30000&wowzaplayduration=40000

Smooth Streaming

 
http://[wowza-ip-address]:1935/vod/mp4:sample.mp4/Manifest?wowzaplaystart=30000&wowzaplayduration=40000
Note:To use the query string method with Silverlight, you may need to use the escape code for the & character in the the URL. For example:
http://[wowza-ip-address]:1935/vod/mp4:sample.mp4/Manifest?wowzaplaystart=30000&wowzaplayduration=40000

Specify start time and duration in SMIL files

In SMIL files, use the begin and dur attributes. The time values for these attributes are specified in seconds:
<smil>
	<head>
	</head>
	<body>
		<switch>
			<video begin="30.0" dur="40.0" src="mp4:sample.mp4" system-bitrate="450000"/>
		</switch>
	</body>
</smil>

Specify start time and duration by using the server-side API

You can specify the playStart and playDuration times through the IHTTPStreamerSession session API. The time values are specified in milliseconds. For example, you can use the following method in a module:
public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
{
	httpSession.setPlayStart(30000);
	httpSession.setPlayDuration(40000);
}

Specify start time and duration by using the MediaList API

The time values are specified in milliseconds:
public class ModuleAMLSTTest extends ModuleBase implements IMediaListProvider
{
	public void onAppStart(IApplicationInstance appInstance)
	{
		appInstance.setMediaListProvider(this);
	}

	public MediaList resolveMediaList(IMediaListReader mediaListReader, IMediaStream stream, String streamName)
	{
		MediaList mediaList = new MediaList();

		MediaListSegment segment = new MediaListSegment();
		mediaList.addSegment(segment);

		MediaListRendition rendition1 = new MediaListRendition();
		segment.addRendition(rendition1);

		rendition1.setName("mp4:sample.mp4");
		rendition1.setBitrateAudio(128000);
		rendition1.setBitrateVideo(400000);
		rendition1.setWidth(320);
		rendition1.setHeight(240);
		rendition1.setPlayStart(30000);
		rendition1.setPlayDuration(40000);

		return mediaList;
	}
}

Originally Published: 10-09-2011.
Updated: 08-24-2015.
 

If you're having problems or want to discuss this article, post in our forum.