Wowza Community

Insert mid roll when live stream is paused java

Hello
I have a simple HTTP module i use to start and stop recording of my live stream.
Essentially, from my app i send network request with command ‘start’ and inside my module i do
StreamRecorderParameters recordParams = new StreamRecorderParameters(appInstance); recordParams.versioningOption = IStreamRecorderConstants.APPEND_FILE; recordParams.fileFormat = IStreamRecorderConstants.FORMAT_MP4; recordParams.segmentationType = IStreamRecorderConstants.SEGMENT_NONE; recordParams.startOnKeyFrame = true; recordParams.recordData = true; vhost.getLiveStreamRecordManager().startRecording(appInstance, recordParams);
Which starts the recording.
Then, when i get the ‘stop’ command, i stop it with
vhost.getLiveStreamRecordManager().stopRecording(appInstance, streamName);

I want to play local file as a midroll when stream gets paused, so when i get the ‘stop’ command i would do something like

			vhost.getLiveStreamRecordManager().stopRecording(appInstance, recordParams);
			Stream stream1 = Stream.createInstance(vhost, "live", streamName);
			stream1.play("mp4:sample.mp4", 0, 5, true);

And then when i get the ‘start’ command it should carry on with recording live stream.

I lack the expertise it seems, can someone point me in the rigth direction? Any advice/link to docs would be appreciated.

You can create a Stream object and a Playlist object. Then add your Live stream to the playlist and play the playlist on the newly created stream. When you stop recording, you can either remove the Live stream from the playlist and replace it with an MP4, or you can create a new Playlist object, add the MP4, and open that new playlist on the outgoing Stream.

NB! Make sure that your Live stream and the MP4 have the same specs (same frame rate and GOP at least, preferably also same picture size) or the transmuxer(s) may be confused and that may cause the player to stop.