# Embed cue points in live-record.

**URL:** <https://community.wowza.com/t/embed-cue-points-in-live-record/41559>\
**Category:** Wowza Streaming Engine\
**Created:** [November 11, 2013, 2:57pm UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559 "2013-11-11T14:57:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam\_Kazi](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Adam\_Kazi](https://community.wowza.com/u/Adam_Kazi)\
**Post date:** [November 11, 2013, 2:57pm UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/1 "2013-11-11T14:57:27Z")

</div>

hey im new to wowza.

i have followed the link [https://www.wowza.com/docs/how-to-inject-cue-points-or-metadata](https://www.wowza.com/docs/how-to-inject-cue-points-or-metadata)

to inject cue points . im able to read data passed from flex app to wowza media server . but im unable to inject cue points in live stream and record it. please help

---

<div class="post-metadata">

**Author:** ![Adam\_Kazi](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Adam\_Kazi](https://community.wowza.com/u/Adam_Kazi)\
**Post date:** [November 11, 2013, 3:55pm UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/2 "2013-11-11T15:55:35Z")

</div>

im working on an application where i need to inject cue points in live stream .

when i change my power point slide i would like to inject a cue point with timestamp in my video and record the same video . i followed the link “[https://www.wowza.com/forums/showthread.php?5151-adding-event-to-while-recording&p=129534#post129534](https://www.wowza.com/forums/showthread.php?5151-adding-event-to-while-recording&p=129534#post129534)” . im able to read data sent from the client publisher to the server . but i cannot send the data to the subscribing clients .

i have written nc.call for publishing client.

this is my server side code

public void setCaption(IClient client, RequestFunction function,AMFDataList params) {

String streamname = params.getString(PARAM1);

AMFDataObj obj = params.getObject(PARAM2);

String caption = obj.getString(“caption”);

String timestamp = obj.getString(“timestamp”);

System.out.println("STREAM-NAME " + streamname);

System.out.println("CAPTION " + caption);

System.out.println("TIMESTAMP " + timestamp);

try {

IMediaStream stream = client.getAppInstance().getStreams().getStream(str eamname);

//long cuePointTime=stream.getMaxTimecode()+ new java.util.Date().getTime();

[//System.out.println](https://System.out.println)("CuePointTime ::::::: "+cuePointTime);

AMFDataList amfList = new AMFDataList();

AMFDataMixedArray data = new AMFDataMixedArray();

data.put(“caption”, new AMFDataItem(caption));

data.put(“timestamp”, new AMFDataItem(timestamp));

// amfList.add(new AMFDataItem(“onCuePoint”));

amfList.add(new AMFDataItem(“setCaption”));

amfList.add(data);

String streamtype = stream.getClient().getAppInstance()

.getStreamType().substring(0, 11);

System.out.println("StreamType :::::: " + streamtype);

if (streamtype.equalsIgnoreCase(“live-record”)) {

stream.send(“setCaption”, data); // this works on the live

// stream.

System.out.println("data :::: " + data.toString());

}

byte[] dataData = amfList.serialize();

int size = dataData.length;

synchronized (stream) {

long timecode = Math.max(stream.getAudioTC(),stream.getVideoTC());

stream.setDataTC(timecode);

stream.setDataSize(size);

stream.addDataData(dataData, 0, size);

}

} catch (Exception e) {

e.printStackTrace();

}

getLogger().info("Caption: " + caption);

}

can u please lemme know where im gng wrong . thanking you in anticipation .

aiman kazi

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 11, 2013, 7:16pm UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/3 "2013-11-11T19:16:22Z")

</div>

aiman,

Use IMediaStream.sendDirect() instead of .send() to record the cueponts

Change this:

```auto
stream.send("setCaption", data); // this works on the live 

```

To this:

```auto
stream.sendDirect("setCaption", data); 

```

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 12, 2013, 6:35pm UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/4 "2013-11-12T18:35:47Z")

</div>

You are mixing legacy method with current method. Take at the [setCaption method in this example](https://www.wowza.com/docs/how-to-inject-cue-points-or-metadata)

The example at bottom shows the legacy method. Follow the example at top.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 25, 2013, 9:59pm UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/5 "2013-11-25T21:59:00Z")

</div>

The easiest way is try to read them in a Flash application. For example if you inject a very simple cuepoint named “testCuepoint” that included AMFDataMixedDataArray that contained one element named “text”, like this:

```auto
String streamname = "myStream";
String cuepointName = "testCuepoint";
String cuepointText = "cuepoint text test test;
IMediaStream stream = client.getAppInstance().getStreams().getStream(streamname);
AMFDataMixedArray data = new AMFDataMixedArray();
data.put("text", new AMFDataItem(cuepointText));
stream.sendDirect(cuepointName, data);

```

… you can read that in the live stream or the recorded file (if you recorded mySteam) like this:

```auto
var nsPlayClientObj:Object = new Object();
nsPlay.client = nsPlayClientObj;
			
nsPlayClientObj.testCuepoint = function(obj:Object):void
{
	alert(obj.text);
}
nsPlay.play(streamname);

```

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 25, 2013, 10:31pm UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/6 "2013-11-25T22:31:40Z")

</div>

Actually, an easier way is to open the video file in a text editor and search for the name of the cuepoint. Following each occurence you will see the data for that cuepoint

Richard

---

<div class="post-metadata">

**Author:** ![Adam\_Kazi](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Adam\_Kazi](https://community.wowza.com/u/Adam_Kazi)\
**Post date:** [November 12, 2013, 11:03am UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/7 "2013-11-12T11:03:22Z")

</div>

thanks richard . i will try the code and reply …

---

<div class="post-metadata">

**Author:** ![Adam\_Kazi](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Adam\_Kazi](https://community.wowza.com/u/Adam_Kazi)\
**Post date:** [November 12, 2013, 12:58pm UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/8 "2013-11-12T12:58:09Z")

</div>

here is my java code for wowza server project .

package com.wowza.example.module;

import com.wowza.wms.amf.\*;

import com.wowza.wms.client.\*;

import com.wowza.wms.module.\*;

import com.wowza.wms.request.\*;

import com.wowza.wms.stream.\*;

public class ModuleInjectData1 extends ModuleBase {

public void setTag (IClient client, RequestFunction function, AMFDataList params)

{

String streamname = params.getString(PARAM1);

String caption = params.getString(PARAM2);

System.out.println("StreamName:: " +streamname);

System.out.println("Caption :: " +caption);

IMediaStream stream = client.getAppInstance().getStreams().getStream(streamname);

System.out.println("Stream :: " +streamname.toString()) ;

AMFDataList amfList = new AMFDataList();

AMFDataMixedArray data = new AMFDataMixedArray();

data.put(“caption”, new AMFDataItem(caption));

amfList.add(new AMFDataItem(“setCaption”));

amfList.add(data);

String streamtype = stream.getClient().getAppInstance().getStreamType();

System.out.println("Stream Type :: " + streamtype);

if (streamtype.equals(“live”))

{

stream.send(“setCaption”, caption); // this works on the live stream.

stream.sendDirect(“setCaption”, caption);

System.out.println("Live Record Caption :: " + caption);

}

byte[] dataData = amfList.serialize();

int size = dataData.length;

synchronized(stream)

{

long timecode = Math.max(stream.getAudioTC(), stream.getVideoTC());

System.out.println("timecode :: " + timecode);

stream.setDataTC(timecode);

stream.setDataSize(size);

stream.addDataData(dataData, 0, size);

stream.sendDirect(“setCaption”, caption);

}

// System.out.println(“Before Thread…”);

// try{

//

// Thread.sleep(1000);

// }catch(Exception e){

// e.printStackTrace();

// }

// System.out.println(“After Thread…”);

//

injectMetaData(client , function , params);

getLogger().info("Caption: " + caption);

}

public void injectMetaData(IClient client, RequestFunction function, AMFDataList params)

{

System.out.println("Inside injectMetaData ::: AIMAN ");

String streamName = params.getString(PARAM1);

String data = params.getString(PARAM2);

IMediaStream stream = client.getAppInstance().getStreams().getStream(streamName);

if (stream != null)

{

AMFDataList amfList = new AMFDataList();

amfList.add(new AMFDataItem("@setDataFrame"));

amfList.add(new AMFDataItem(“onMetaData”));

AMFDataMixedArray metaData = new AMFDataMixedArray();

metaData.put(“param1”, data);

metaData.put(“param2”, new AMFDataItem(“data2”));

amfList.add(metaData);

synchronized(stream)

{

byte[] dataData = amfList.serialize();

System.out.println(“dataData ::” +dataData.toString());

int size = dataData.length;

System.out.println("size :: " + size);

long timecode = Math.max(stream.getAudioTC(), stream.getVideoTC());

System.out.println(“timecode ::” +timecode);

stream.setDataTC(timecode);

stream.setDataSize(size);

stream.startDataPacket();

stream.addDataData(dataData, 0, size);

stream.sendDirect(“streaming”, amfList );

}

}

}

}

as3 code from flex app

protected function sendData\_clickHandler(event:MouseEvent):void

{

// TODO Auto-generated method stub

\_nc.call(“setTag”,null,“livefeed”,“hello room”,“eng”,“0”);

}

private function streaming(obj:Object):void

{

var a:String = obj.toString();

textbox.text = a + “\n” ;

}

i get error message . i have used stream.sendDirect();

please let me know where im gng wrong.

my error in java :

INFO session connect-pending 127.0.0.1 -

INFO session connect 127.0.0.1 -

INFO stream create - -

INFO stream play livefeed -

StreamName:: livefeed

Caption :: hello room

Stream :: livefeed

Stream Type :: live

Live Record Caption :: hello room

timecode :: 8508

Inside injectMetaData ::: AIMAN

dataData ::[B@6b543e44

size :: 74

timecode ::8508

WARN server comment - LiveReceiver.startDataPacket[test/_definst_/livefeed]: Data packet sync issue.

ERROR server comment - addDataA[this.size:26 this.dataA.length:26 this.startDataLoc:0 this.dataLoc:0 data.length:74 offset:0 size:74 missing:26]: java.lang.ArrayIndexOutOfBoundsException

java.lang.ArrayIndexOutOfBoundsException

INFO server comment - Caption: hello room

WARN server comment - LiveReceiver.startDataPacket[test/_definst_/livefeed]: Data packet sync issue.

at java.lang.System.arraycopy(Native Method)

at com.wowza.wms.amf.AMFPacket.addData(Unknown Source)

at com.wowza.wms.stream.live.LiveReceiver.addDataData(Unknown Source)

at com.wowza.wms.stream.live.MediaStreamLive.addDataData(Unknown Source)

at com.wowza.example.module.ModuleInjectData1.injectMetaData(ModuleInjectData1.java:94)

at com.wowza.example.module.ModuleInjectData1.setTag(ModuleInjectData1.java:59)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.wowza.wms.module.ModuleFunction.invoke(Unknown Source)

at com.wowza.wms.module.ModuleFunctions.invoke(Unknown Source)

at com.wowza.wms.request.RequestProcessFunctions.processFunctions(Unknown Source)

at com.wowza.wms.request.RequestProcessData.flushFunction(Unknown Source)

at com.wowza.wms.request.RequestProcessData.processNextRequest(Unknown Source)

at com.wowza.wms.client.ClientWorker.processNextReq(Unknown Source)

at com.wowza.wms.request.RTMPRequestAdapter.service(Unknown Source)

at com.wowza.wms.server.ServerHandler.a(Unknown Source)

at com.wowza.wms.server.ServerHandler.a(Unknown Source)

at com.wowza.wms.server.ServerHandler.messageReceived(Unknown Source)

at com.wowza.wms.server.ServerHandlerThreadedSession.run(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

INFO stream stop livefeed -

INFO stream destroy livefeed -

INFO session disconnect 2131692034 -

---

<div class="post-metadata">

**Author:** ![Adam\_Kazi](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Adam\_Kazi](https://community.wowza.com/u/Adam_Kazi)\
**Post date:** [November 25, 2013, 11:09am UTC](https://community.wowza.com/t/embed-cue-points-in-live-record/41559/9 "2013-11-25T11:09:21Z")

</div>

how will i come to know if i have embedded cue points in my live-record video file
