Wowza Community

How to change segment_duration parameters during recording

Hi,
I want to control the recorder of wowza server in the viewer using HTTP provider.
So implemented the ability to start recording, stop recording, and change file storage locations.
But couldn’t find a function in java api that modifies the set parameters for the recorder being recorded.

ex) setRecorderParams()…? setParams()…?

So I had to stop the recorder in the following way first and then set the parameter again and use the method to start it.

private void switchRecording(IVHost vhost, String streamName, long duration) {
	// 1. Stop Existing Recorder
	IStreamRecorder recorder = vhost.getLiveStreamRecordManager().getRecorder(this.appInstance, streamName);
	recorder.stopRecorder();
	
	// 2. Define new params
	StreamRecorderParameters newRecordParams = new StreamRecorderParameters(this.appInstance);
	newRecordParams.fileFormat = IStreamRecorderConstants.FORMAT_MP4;
	newRecordParams.fileTemplate = "${SourceStreamName}_${SegmentTime}_${SegmentNumber}";
	newRecordParams.outputPath = appInstance.getStreamStorageDir() + "/" + streamName;
	File folder = new File(newRecordParams.outputPath);
	if(!folder.exists()) {
		WMSLoggerFactory.getLogger(CLASS).error(CLASSNAME + " Folder Not Found : " + newRecordParams.outputPath);
		WMSLoggerFactory.getLogger(CLASS).error(CLASSNAME + " Make Dir : " + newRecordParams.outputPath);
		folder.mkdir();
	}
	newRecordParams.segmentationType = IStreamRecorderConstants.SEGMENT_BY_DURATION;
	newRecordParams.segmentDuration = duration;
	
	// 3. New Recorder start
	vhost.getLiveStreamRecordManager().startRecording(this.appInstance, streamName, newRecordParams);
}

But I believe there’s a better way. Is there an asynchronous way to change the parameters of the recorder that is being recorded continuously without interrupting the existing recorder?

Is there a function that implements the function I want? If so, which object or interface is defined?
I’d appreciate your help.

Let me look into this for you.

It’s not easy, because the StreamRecorder instance passes the values of each of the params to the internal recorder when it is started, instead of the internal recorder reading the values each time.

Instead of trying to reconfigure the existing recorder, a much better approach would be to stop & start the recorder if you need to make a change. You can use the onSegmentEnd method to get a notification when the current recorded segment ends and then you can use that point to reconfigure and restart the recorder.

If file naming is an issue, then you can use a custom IStreamRecorderFileVersionDelegate to do your own naming. If you do want to go down the route of reconfiguring the recorder on the fly, then you would need to implement IStreamRecorderActionNotify and then create your own internal recorder ( LiveStreamRecorderMP4 ) in onCreateRecorder(streamRecorder) and then call streamRecorder.setInternalRecorder(myRecorder) to set it.

Because you have created it, you will have to completely configure it and start it. You can do this in the onStartRecorder(streamRecorder) method. You will then be able to change any settings they need to on the internal recorder.This method isn’t documented and isn’t recommended without advanced knowledge and experience.

If you need any assistance with the custom configuration, you can post in the Hire A Consultant forum here or contact the Wowza Pro Services team.

I hope this information makes it clear what your options are @thousand_wise_winner