Wowza Community

Selecting transcoder profile on server side API

Hi there … I want to use something like mentioned on following post to select which stream to transcode (https://www.wowza.com/docs/how-to-control-which-streams-get-transcoded-using-server-side-api)

Is there any way to select at same time, through server side API, which transcoder profile to use for each stream?

I want to tell which stream to transcode, and which profile of the 3 I will have to use for each stream

Thanks in advance

Hi,

The easiest way to do this will be to implement the ILiveStreamTranscoderActionNotify interface which has a method, onInitBeforeLoadTemplate(LiveStreamTranscoder liveStreamTranscoder);, which is called right before the template is loaded. In this method, you can specify the name of the template that you want to load.

To implement the interface, you can do the following.

[PHP]

// Add a Transcoder listener to the appInstance.

appInstance.addLiveStreamTranscoderListener(new MyTranscoderCreateNotifier());

. . .

// Listener class that listens for transcoder create events and registers the transcoder action notifier class.

class MyTranscoderCreateNotifier implements ILiveStreamTranscoderNotify

{

@Override

public void onLiveStreamTranscoderCreate(ILiveStreamTranscoder liveStreamTranscoder, IMediaStream stream)

{

((LiveStreamTranscoder)liveStreamTranscoder).addActionListener(new MyTranscoderActionNotifier());

}

@Override

public void onLiveStreamTranscoderDestroy(ILiveStreamTranscoder liveStreamTranscoder, IMediaStream stream)

{

}

@Override

public void onLiveStreamTranscoderInit(ILiveStreamTranscoder liveStreamTranscoder, IMediaStream stream)

{

}

}

// Listener class that listens for transcoder actions. This class extends LiveStreamTranscoderActionNotifyBase which already implements all of the ILiveStreamTranscoderActionNotify methods so you only override the methods you need.

class MyTranscoderActionNotifier extends LiveStreamTranscoderActionNotifyBase

{

// get the templateName from somewhere and set it here.

@Override

public void onInitBeforeLoadTemplate(LiveStreamTranscoder liveStreamTranscoder)

{

String templateName = “myStream.xml”;

liveStreamTranscoder.setTemplateName(templateName);

}

}

[/PHP]

You can also use this along side the transcoder control interface to control what actually gets transcoded.

Roger.

To expand this a little, can you specify the name of the template that you want to load in the stream name used on the encoder?

For example:

Server URL: rtmp://10.10.10.10/live
Stream name: myStream,transrate1

Results in rtmp://10.10.10.10/live/myStream being transcoded with the settings in transrate1.xml

Server URL: rtmp://10.10.10.10/live
Stream name: myStream,transrate8

Results in rtmp://10.10.10.10/live/myStream being transcoded with the settings in transrate8.xml

Is it doable?