# How to change segment\_duration parameters during recording

**URL:** <https://community.wowza.com/t/how-to-change-segment-duration-parameters-during-recording/92968>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [March 11, 2021, 6:54am UTC](https://community.wowza.com/t/how-to-change-segment-duration-parameters-during-recording/92968 "2021-03-11T06:54:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thousand\_wise\_winner](https://avatars.discourse-cdn.com/v4/letter/t/e47774/32.png) [@thousand\_wise\_winner](https://community.wowza.com/u/thousand_wise_winner)\
**Post date:** [March 11, 2021, 6:54am UTC](https://community.wowza.com/t/how-to-change-segment-duration-parameters-during-recording/92968/1 "2021-03-11T06:54:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![video\_streaming](https://avatars.discourse-cdn.com/v4/letter/v/22d042/32.png) [@video\_streaming](https://community.wowza.com/u/video_streaming)\
**Post date:** [March 11, 2021, 10:50pm UTC](https://community.wowza.com/t/how-to-change-segment-duration-parameters-during-recording/92968/2 "2021-03-11T22:50:37Z")

</div>

Let me look into this for you.

---

<div class="post-metadata">

**Author:** ![video\_streaming](https://avatars.discourse-cdn.com/v4/letter/v/22d042/32.png) [@video\_streaming](https://community.wowza.com/u/video_streaming)\
**Post date:** [March 12, 2021, 2:48pm UTC](https://community.wowza.com/t/how-to-change-segment-duration-parameters-during-recording/92968/3 "2021-03-12T14:48:52Z")

</div>

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
