# Programmatic Control of the Transcoder

**URL:** <https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856>\
**Category:** Wowza Streaming Engine\
**Created:** [June 5, 2015, 2:02pm UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856 "2015-06-05T14:02:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henry\_Clout](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@Henry\_Clout](https://community.wowza.com/u/Henry_Clout)\
**Post date:** [June 5, 2015, 2:02pm UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856/1 "2015-06-05T14:02:17Z")

</div>

Hi there.

We would like to control the number and bitrate of the HLS levels generated on an input stream by input stream basis. We would like to do this dynamically, so I would assume programmatically.

For instance:

- When receiving stream name abc, transcode to: 2 levels @1Mb and 2Mb

- When receiving stream name xyz, transcode to: 3 levels @500kb, 1Mb, 3Mb

I’ve had a look through the forums and the API and haven’t been able to figure out if this is possible. Could you let me know if (and if so, how) there is a way to do this please?

Thanks,

Henry

---

<div class="post-metadata">

**Author:** ![sal\_jefferson](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sal\_jefferson](https://community.wowza.com/u/sal_jefferson)\
**Post date:** [June 5, 2015, 10:09am UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856/2 "2015-06-05T10:09:20Z")

</div>

Hi Henry.

You can match template names with stream names, and remove the specific template name (i.e.transrate.xml, transcode.xml) from Application.xml file.

```auto
<Templates>${SourceStreamName}.xml</Templates>

```

if you only have a template named myStream.xml you will only transcode streams named myStream. if you also have a template named yourStream.xml, streams named “myStream” and “yourStream” will be transcoded using those templates, and other streams will not be transcoded.

Salvadore

---

<div class="post-metadata">

**Author:** ![sal\_jefferson](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sal\_jefferson](https://community.wowza.com/u/sal_jefferson)\
**Post date:** [June 8, 2015, 7:15am UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856/3 "2015-06-08T07:15:09Z")

</div>

You’re welcome Henry.

I do not have an answer for your last question. Best I can do is send your request on to Wowza as a feature request.

Best,

Salvadore

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [June 12, 2015, 7:34am UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856/4 "2015-06-12T07:34:07Z")

</div>

Hello

You could take a look at the ILiveStreamTranscoderNotify and ILiveStreamTranscoderActionNotify interfaces. and dynamically choose your template file. Setup the following event handlers as indicated in this [post](http://community.wowza.com/t/-/35562). Then you can choose the template required by leveraging the liveStreamTranscoder object within the ILiveStreamTranscoderActionNotify.onInitBeforeLoadTemplate event handler as follows:

```auto
liveStreamTranscoder.setTemplateName("TemplateName.xml");

```

Thanks,

Matt

---

<div class="post-metadata">

**Author:** ![Henry\_Clout](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@Henry\_Clout](https://community.wowza.com/u/Henry_Clout)\
**Post date:** [June 8, 2015, 8:00am UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856/5 "2015-06-08T08:00:24Z")

</div>

Hi Salvadore.

Thanks for this!

Are there any plans to support dynamic configuration of the transcode parameters in the future? (rather than having to pre-define rates in XML)

Henry

---

<div class="post-metadata">

**Author:** ![Henry\_Clout](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@Henry\_Clout](https://community.wowza.com/u/Henry_Clout)\
**Post date:** [June 10, 2015, 7:29am UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856/6 "2015-06-10T07:29:15Z")

</div>

Great, thanks Salvadore!

Yours,

Henry

---

<div class="post-metadata">

**Author:** ![Henry\_Clout](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@Henry\_Clout](https://community.wowza.com/u/Henry_Clout)\
**Post date:** [July 3, 2015, 3:54pm UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856/7 "2015-07-03T15:54:21Z")

</div>

Thanks Matt. There are two problems I see with this approach :

i) The best we can manage is ‘notchy’ levels, i.e. preset levels defined in the XML. It would be ‘nicer’ if we had full, programmatic control, but I guess predefined is acceptable. Furthermore, there’s no other solution, so we don’t have a lot of choice but to accept it 🙂

ii) If we want to dynamically enable/disable on a per HLS level basis (e.g. enable 128k, disable 256k, enable 512k, enable 1Mb) then we’ll need XML templates containing all the permutations of these combinations. This is kind of a pain.

Am I missing something, or is this the case? Any thoughts as to a more elegant solution to ii) ?

Thanks,

Henry

---

<div class="post-metadata">

**Author:** ![Henry\_Clout](https://avatars.discourse-cdn.com/v4/letter/h/a9adbd/32.png) [@Henry\_Clout](https://community.wowza.com/u/Henry_Clout)\
**Post date:** [July 7, 2015, 10:33am UTC](https://community.wowza.com/t/programmatic-control-of-the-transcoder/41856/8 "2015-07-07T10:33:29Z")

</div>

I think I’ve come up with a way of working around the requirement to have templates containing all the permutations of levels. The proposed solution is:

1. Set up a transcode template per level (200k, 500k, 1Mb, etc, etc)

2. Issue an call to our HTTProvider2Base based plugin to Wowza saying stream name: abc123 should use templates: 200k.xml, 1Mb.xml

3. Add code to our Wowza plugin to start transcoders with the profiles listed in 2) when we start receiving the stream name defined in 1)

4. Generate the root m3u8 in our (separate) application which proxies m3u8 calls to Wowza and references the specific levels generated.

I _think_ this should work and give us the flexibility we require.

The only catch is with implementing 3). I can see in the Application.xml file that you can specify multiple transcode templates:

transcoder

**audioonly.xml**

${com.wowza.wms.context.VHostConfigHome}/transcoder/profiles

${com.wowza.wms.context.VHostConfigHome}/transcoder/templates

But I haven’t figured out how to do this from the API. I’m hoping that one of the callbacks allows you to configure the template names to use for a given stream.

Could you point me in the direction of such a call please?
