Wowza Community

Set start and duration to rtmp is indistinct


I’m using Wowza 3.5 and JWPlayer 6 and I’m trying to specify start and duration for on demand video (rtmp).

For that :

  • I’m using an override for play method on a class who extends ModuleBase :


public void play(IClient client, RequestFunction function, AMFDataList params) throws MalformedURLException {

URL url = new URL(client.getPageUrl());

Map<String,String> urlParameters = getQueryMap(url.getQuery());

//Calcul de l’extrait au besoin.

double start = Double.parseDouble(urlParameters.get(“tcin”));

double duration = Double.parseDouble(urlParameters.get(“tcout”)) - start;

String streamName = params.getString(PARAM1);

IMediaStream stream =getStream(client, function);

//On réaffecte la durée du stream.

AMFDataList customDataList = new AMFDataList();





customDataList.add(new AMFDataItem(start)); // start value in milliseconds

customDataList.add(new AMFDataItem(duration)); //duration (-1 means play to the end). Value in milliseconds.

customDataList.add(new AMFDataItem(true)); //reset

invokePrevious(this, client, function, customDataList);

//Stockage de la durée de l’extrait dans les propriétés du stream pour l’extraire ensuite dans la classe MyMediaReaderMP4InjectMetadata

stream.getProperties().put(“overrideDuration”, duration/1000);



  • I’m using an override for getMetadata method on a class who extends MediaReaderH264 (and set its className in MediasReader.xml) :


public List getMetadata(){

List ret = super.getMetadata();

WMSLogger getLogger = WMSLoggerFactory.getLogger(null);

// Here the calculated duration stored by above is extracted.

// Note that the default duration is used if there is no duration property in the stream, so simple video streaming will work as usual

double overrideDuration =“overrideDuration”, (double) this.duration / 1000); // Value in seconds."CIMUMediaReaderMP4InjectMetadata_overrideDuration: " + overrideDuration);


if (ret == null)


if (ret.size() <= 0)


ByteBuffer packet = ret.get(0);

AMFDataList myMetadata = new AMFDataList(packet);

AMFDataMixedArray dataObj = (AMFDataMixedArray)myMetadata.get(1);

dataObj.put(“duration”, new AMFDataItem(overrideDuration)); // duration in seconds.

byte[] data = myMetadata.serialize();

ByteBuffer newPacket = ByteBuffer.wrap(data);

ret.set(0, newPacket);



return ret;



It’s approximately working, but i’m encountering a strange behavior :

I’m trying to extract 5 seconds from video @ 10seconds from beginning

=> I’m setting start value to 10000

=> I’m setting duration value to 5000

=> I’m setting overrideDuration value to 5000

From webInterface, when I play video, its duration is longer than 5 seconds (approximately 7 seconds) but value on JWPlayer is 5

=> JWPlayer slider is out of 0 - 5duration @ end of video

Screen :

Video are really longer than 5 seconds but duration was set to 5000 in play method.

Any ideas for that ?

Thanks for reading