Creating a MediaListRendition from a stream name?

Hey guys,

Some background: I’m building a module designed to automatically create grouped manifest/playlist files for multiple streams. This is very similar to what ngrp: does for grouped streams in the transcoder – but I have specific requirements where I need other streams grouped as well. My approach has been to create an IMediaListProvider module to return the manifest/playlist from a set of renditions within the amlst: namespace.

The question: Given only the name of a live stream, how can I build a rendition object complete with width, height, bitrates and codecs?

The simple way to illustrate the question is in code: What would I write in resolveMediaListRendition()?

package com.wowza.wms.plugin.testing;

import com.wowza.wms.medialist.*;

import com.wowza.wms.util.*;

import com.wowza.wms.module.*;

import com.wowza.wms.stream.*;

import com.wowza.wms.application.*;

import java.util.*;

public class ModuleTestingStreamList extends ModuleBase implements IMediaListProvider {

private IApplicationInstance appInstance = null;

public MediaListRendition resolveMediaListRendition(String streamName) {

// … do stuff to create a MediaListRendition streamRendition from the streamName

return streamRendition;

}

public MediaList resolveMediaList(IMediaListReader mediaListReader, IMediaStream stream, String streamName) {

MediaList mediaList = new MediaList();

MediaListSegment segment = new MediaListSegment();

mediaList.addSegment(segment);

List streams = this.appInstance.getStreams().getPublishStreamNames();

Iterator streamsIterator = streams.iterator();

while (streamsIterator.hasNext()) {

String renditionStreamName = streamsIterator.next();

segment.addRendition(resolveMediaListRendition(renditionStreamName));

}

return mediaList;

}

public void onAppStart(IApplicationInstance appInstance) {

this.appInstance = appInstance;

this.appInstance.setMediaListProvider(this);

}

}

Thanks,

Steffen

Hi Steffen,

Have you seen the AMLST example?

The streams you reference have to exist. You probably need some naming scheme to iterate over the renditions starting with a base stream name.

You can get frame size and codec info from IMediaStreamActionNotify3onCodecInfoVideo() and IMediaStreamActionNotify3onCodecInfoAudio(), and IMediaStreamActionNotify3onMetaData(), the

With that in place, you can store info in the stream then retrieve it in the IMediaListProvider using WMSProperties.

public void onCodecInfoVideo(IMediaStream stream,
				MediaCodecInfoVideo codecInfoVideo) {
				stream.getProperties().setProperty("videocodec", codecInfoVideo.toCodecsStr());
		
		}

Then you can get that in IMediaListProvider:

while (streamsIterator.hasNext())
		{
			IMediaStream _stream = this.appInstance().getStreams().getStream(streamsIterator.next());
			String videocodec = _stream.getProperties().getPropertyStr("videocodec");

You could use the naming convention for bitrate. In your encoder or with Wowza Transcoder, name each rendition according to the bitrate of the stream: myStream_360p

Richard

Thanks Richard – that’s actually extremely close to where I ended up myself: Naming schemes to iterate over relevant streams; bit rate in stream names; listening directly to events about meta data.

My initial assumption was that I’d be able to get away with less heavy lifting in detecting codecs and formats since my code overlaps with what’s already being done for the streams already.

Having said that though, it turned out to be pretty easy to build.

Thanks for all the help,

Steffen