We have a continuous live stream we are running through Wowza Streaming Engine and transcoding to a few bitrates and pushing the RTMP to Akamai. I’d like to be able to programmatically insert a 30 second mp3 promo/ad into the stream, then switch back to the original live source, without stopping the stream or restarting the application.
The closest forum I see is:
https://www.wowza.com/docs/how-to-switch-streams-using-stream-class-streams however, this appears to create multiple playlists, one for each asset.
I’ve coded it so we have an HTTProvider2Base that I can pass which promo I’d like to switch to, then be able to switch back to the live stream.
I’m seeing a few things that I don’t understand:
1.) When I make a call to switch playlists, it takes about 5 seconds for the new assets to start playing, and there is buffering before it begins to play.
2.) If I create a playlist that is a promo, then the live stream in the same playlist, the transition is instantaneous. Why is this different than #1?
3.) We are trying to push our transcoded streams to Akamai, but it appears every time you switch the playlist, the transcoder is reset, and this seems to break the stream Akamai is trying to read.
4.) The publishStream doesn’t seem to start right away. Do I need to be waiting for a callback before the startMediaCasterStream is finished before I can push that playlist into a stream?
Here is some of the code we are using:
String theStreamName = "publishStream";
String streamName = "audio_stream.stream";
if( action.equalsIgnoreCase( "start" ) )
{
appInstance.startMediaCasterStream(streamName, streamType);
Stream stream = Stream.createInstance(appInstance, theStreamName);
appInstance.getProperties().setProperty(theStreamName, stream);
Playlist start_playlist = new Playlist("start");
start_playlist.open(stream);
WMSLoggerFactory.getLogger(null).info("AMVDM.API: startMediaCasterStream: streamName: " + streamName + " & streamType: " + streamType);
retStr = "<html><head><title>" + streamName
+ "</title></head><body>" + streamName + " has been started</body></html>";
}
else if( action.equalsIgnoreCase( "stop" ) )
{
appInstance.stopMediaCasterStream(streamName);
WMSLoggerFactory.getLogger(null).info("AMVDM.API: stopMediaCasterStream: streamName: " + streamName);
retStr = "<html><head><title>" + streamName
+ "</title></head><body>" + streamName + " has been stopped</body></html>";
}
else if( action.equalsIgnoreCase( "play_promo" ))
{
Playlist promo_playlist = new Playlist("promo");
promo_playlist.addItem("mp3:psa.mp3", 0, -1);
promo_playlist.addItem( streamName, -2, -1);
appInstance.getProperties().setProperty( promo_playlist.getName(), promo_playlist );
Stream stream = (Stream)appInstance.getProperties().getProperty(theStreamName);
promo_playlist.open(stream);
WMSLoggerFactory.getLogger(null).info( "AMVDM.API: switching to promo: streamName: " + streamName );
retStr = "<html><head><title>" + streamName
+ "</title></head><body>" + streamName + " has been switched to a promo</body></html>";
}
else if( action.equalsIgnoreCase( "play_live_stream" ))
{
Playlist livestream_playlist = new Playlist("livestream");
livestream_playlist.addItem( streamName, -2, -1);
appInstance.getProperties().setProperty( livestream_playlist.getName(), livestream_playlist );
Stream stream = (Stream)appInstance.getProperties().getProperty( theStreamName);
livestream_playlist.open(stream);
WMSLoggerFactory.getLogger(null).info( "AMVDM.API: switching to live stream: streamName: " + streamName );
retStr = "<html><head><title>" + streamName
+ "</title></head><body>" + streamName + " has been switched to the live stream</body></html>";
}
}