# Dynamically Inject Metadata to Live Stream (RTMP and HLS)

**URL:** <https://community.wowza.com/t/dynamically-inject-metadata-to-live-stream-rtmp-and-hls/46623>\
**Category:** Wowza Streaming Engine\
**Created:** [February 23, 2016, 6:03pm UTC](https://community.wowza.com/t/dynamically-inject-metadata-to-live-stream-rtmp-and-hls/46623 "2016-02-23T18:03:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derrick\_Yeung](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@Derrick\_Yeung](https://community.wowza.com/u/Derrick_Yeung)\
**Post date:** [February 23, 2016, 6:03pm UTC](https://community.wowza.com/t/dynamically-inject-metadata-to-live-stream-rtmp-and-hls/46623/1 "2016-02-23T18:03:10Z")

</div>

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.

```auto
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.

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

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

```

What would be the correct way of doing this?

Thanks,

- Derrick

---

<div class="post-metadata">

**Author:** ![Andy\_Engberson](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/andy_engberson/32/392_2.png) [@Andy\_Engberson](https://community.wowza.com/u/Andy_Engberson)\
**Post date:** [April 12, 2016, 11:58pm UTC](https://community.wowza.com/t/dynamically-inject-metadata-to-live-stream-rtmp-and-hls/46623/2 "2016-04-12T23:58:46Z")

</div>

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](https://www.wowza.com/docs/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](https://www.wowza.com/docs/how-to-convert-ontextdata-events-in-a-live-or-vod-stream-to-timed-events-id3-tags-in-an-apple-hls-stream%28ID3-tags%29-in-an-Apple-HLS-stream)

Andy E

---

<div class="post-metadata">

**Author:** ![jojo\_george](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@jojo\_george](https://community.wowza.com/u/jojo_george)\
**Post date:** [June 4, 2018, 10:04am UTC](https://community.wowza.com/t/dynamically-inject-metadata-to-live-stream-rtmp-and-hls/46623/3 "2018-06-04T10:04:32Z")

</div>

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

onMetadata event for getting the metadata.Here is my code

```

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

```
