Wowza Community

Dynamically Inject Metadata to Live Stream (RTMP and HLS)

Hello all,

I am looking for a way to dynamically inject arbitrary metadata (for use as cue point) into a live stream and then get the metadata back in JWPlayer in different browsers (for both RTMP and HLS). After reading through various articles on this forum, I tried the following two methods as part of a HTTPProvider but neither of them works.

Try 1.

private boolean injectMetaData(IMediaStream stream, String payload) {
		if (stream != null) {
			AMFDataObj amfData = new AMFDataObj();
			
			amfData.put("payload", payload);
			stream.sendDirect("payload", amfData);
			return true;
		}
		
		return false;
	}

Try 2.

private boolean injectMetaData(IMediaStream stream, String payload) {
		if (stream != null) {
			AMFDataList amfList = new AMFDataList();
			
			amfList.add(new AMFDataItem("@setDataFrame"));
			amfList.add(new AMFDataItem("onMetaData"));
			
			AMFDataMixedArray metaData = new AMFDataMixedArray();
			
			metaData.put("payload", payload);
			
			amfList.add(metaData);
			
			synchronized(stream) {
				byte[] dataData = amfList.serialize();
				int size = dataData.length;
				long timecode = Math.max(stream.getAudioTC(), stream.getVideoTC());
				
				stream.setDataTC(timecode);
				stream.setDataSize(size);
				stream.startDataPacket();
				stream.addDataData(dataData, 0, size);
			}
			
			return true;
		}
		
		return false;
	}

The calls to the HTTPProvider completed successfully in both cases, but when trying to get the metadata back in JWPlayer in the browser, the custom metadata never showed up.

Here is how I am getting the metadata with JWPlayer:

jwplayer('player').on('meta', function(evt) {
    console.log(evt.metadata);
};

What would be the correct way of doing this?

Thanks,

  • Derrick

The following articles should be helpful.

This is an example of how to inject cue points into a live stream using the onTextData method:

How-to-inject-cue-points-or-metadata

This is an example of how to convert to ID3 tags for use with HLS streams:

How-to-convert-onTextData-events-in-a-live-or-VOD-stream-to-timed-events-(ID3-tags)-in-an-Apple-HLS-stream

Andy E

I am also having the same issue the I have tried wowza player's 

onMetadata event for getting the metadata.Here is my code

metaDataListener = function ( metaDataEvent ) {
  console.log(metaDataEvent);
	
};
myPlayer.onMetadata( metaDataListener );