Wowza Community

Inject Cuepoint

https://www.wowza.com/docs/how-to-inject-cue-points-or-metadata

(Compact version)

Code to inject a cue point that gets recorded and triggered client side from the server side.

Note this requires Wowza Server 2.0.0.15 (patch 15) or higher

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 ModuleInjectCuePoint extends ModuleBase {

	public void setCaption (IClient client, RequestFunction function, AMFDataList params)
	{
		String streamname = params.getString(PARAM1);
		String caption =  params.getString(PARAM2);
		IMediaStream stream = client.getAppInstance().getStreams().getStream(streamname);
		
		//essential code
		AMFDataMixedArray data = new AMFDataMixedArray();
		data.put("caption", new AMFDataItem(capton);
		stream.sendDirect("setCaption", data);

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

Flash Client 1, Live stream player with controls to inject the caption

// call the function:
netconnection.call("setCaption",null,"myStream","hello room");

// set up netstream for the callback on the live stream
nsPlayClientObj:Object = new Object();
nsPlayClientObj.setCaption = function(caption:String):void
{
trace(caption);
}
nsPlay.client = nsPlayClientObj;

Flash Client 2, a vod player

// set up netstream for callback on recorded stream
var nsPlayClientObj:Object = new Object();

nsPlayClientObj.setCaption = function(obj:Object):void
{
	trace(obj.caption)
}
nsPlay.client = nsPlayClientObj;

You can use this method to do it. All the essentials are laid out above. Each translator would be using different cuepoint names, and each JW player would read one of those.

Richard

The code in the top box, is server-side Wowza module for inserting cuepoints.

Each translator would be using a Flash application that uses the code in the middle box which sends commands to the server-side module.

The code in the lower box is the essential code to read a cuepoint in Flash player. You would have to add this to JW player.

Richard

This is new compact version of the code in the first post. The sendDirect method injects the cuepoint into the live stream and recording. The send method only handles the live stream.

Richard

Download patch 18 and it’s in the Server-side API document.

void sendDirect(String handlerName)

Call client side NetStream method/handler and send event to underlying stream (will record

event)

void sendDirect(String handlerName, Object[] params)

Call client side NetStream method/handler and send event to underlying stream (will record

event)

Richard

I added a note to the post:

Note this requires Wowza Server 2.0.0.15 (patch 15) or higher

This is a Wowza Application Module. You need the Wowza IDE to compile this to a jar file in the Wowza lib folder, then you will be adding a Module reference to an Application.xml Modules list. The Wowza IDE is here:

http://wowza.com/ide.html

Download the IDE and read the included guide to get started.

Richard

Doesn’t seem like a good idea, it would not be faster. cuepoints is data stored with the stream. Video, audio, data. SharedObjects are stored on the server. There is also a way to store data in an external file that is called cuepoints, but that’s not the kind of cuepoint generally discussed around streaming media.

Richard

I don’t think so, not that I know of, not with Wowza. That’s the advantage of the external method of cuepoints (xml file) used by many player systems: they are editable.

Richard

JW Player and Flowplayer have a Captions Plugin:

http://www.longtailvideo.com/addons/plugins/84/Captions?q=

http://flowplayer.org/plugins/flash/captions.html

Richard

I thought your issue was editing cuepoints after, i.e., the recorded video.

Richard

I don’t think there is, as I said. You can use an xml solution when you play the recording.

Captionate works with flv files only, under 500mb, and they do not mention editing, just injecting. I’ve never used it.

Richard

nsClientObj:Object = new Object();
nsClientObj.setCaption = function(caption:String):void
{
trace(caption);
}
ns.client = nsClientObj;
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);

Where “setCaption” is the cuepoint name.

Richard

This is ActionScript used in Flash CS authoring tool, or Flex/Flash Builder IDE.

Do you want our list of independent developers? If so, send email to support@wowza.com with link back to this thread.

Richard

I’m using Wowza 3.0 and SendDirect() is not working with VoD streams.

I have to change to Send() for get it to work.

How to use this example reference the code:

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 ModuleInjectCuePoint extends ModuleBase {

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

{

Where put this code I need compile?

thanks for help

I dont quite understand!

With wirecast I’m sending over wowza a lifestream. Our translators sit in different countries and see the lifestream. They translate simultanously and want to inject their translations as subtitles into the livestream. Each language has a separate jw player.

How can my translators send their text to wowza?

Do I need to write a desktop application connecting to wowza(how to connect?) which uses cuepoints to inject the text into the livestream?

Another thing is also how to separate the different languages injected into a single livestream?

What is this bit of code doing?

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);

}

I think

“stream.sendDirect(“setCaption”, data);”

should be

“stream.send(“setCaption”, data);”

In the Wowza IDE and in the documents I cant find a sendDirect method. Can u provide me with a link?