# How to set the stream name to recordParams in Auto Recorder

**URL:** <https://community.wowza.com/t/how-to-set-the-stream-name-to-recordparams-in-auto-recorder/93186>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api, recording\
**Created:** [April 20, 2021, 9:39am UTC](https://community.wowza.com/t/how-to-set-the-stream-name-to-recordparams-in-auto-recorder/93186 "2021-04-20T09:39:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shemar\_Cox](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Shemar\_Cox](https://community.wowza.com/u/Shemar_Cox)\
**Post date:** [April 20, 2021, 9:39am UTC](https://community.wowza.com/t/how-to-set-the-stream-name-to-recordparams-in-auto-recorder/93186/1 "2021-04-20T09:39:27Z")

</div>

hi,  
I am making an automatic recorder referring to the module in the link below.

> **[GitHub - WowzaMediaSystems/wse-plugin-autorecord: Wowza Streaming Engine™ module to record incoming...](https://github.com/WowzaMediaSystems/wse-plugin-autorecord)**
>
> Wowza Streaming Engine™ module to record incoming live streams using application StreamRecorder parameters.

I wrote an additional code in the middle to set my own parameters.  
( **ModuleAutoRecord.java** Between 81 and 83 lines in the original file)

```
	recordParams = new StreamRecorderParameters(appInstance);
	recordParams.fileFormat = IStreamRecorderConstants.FORMAT_MP4;
	recordParams.fileTemplate = "${SourceStreamName}_${SegmentTime}_${SegmentNumber}";
	recordParams.outputPath = "D:/wowza/content/"+"${SourceStreamName}";
	File folder = new File(recordParams.outputPath);
	if(!folder.exists()) {
		folder.mkdirs();
	}
	recordParams.segmentationType = IStreamRecorderConstants.SEGMENT_BY_DURATION;
	recordParams.segmentDuration = 60000;

```

After extracting the module into a jar file and adding it to the system, the system was re-run to verify that the recorder was working.

> INFO server comment - StreamRecorder[live/_definst_] recordStream: action:startRecordingSegmentByDuration stream:myStream1.stream format:mp4 versioning:version outputFile:myStream1.stream.mp4 outputPath:D:/wowza/content/null startOnKeyFrame:true moveFirstVideoFrameToZero:true splitOnTcDiscontinuity:false backBufferTime:0 timeScale:90000 recordData:false segmentDuration:60000 segmentSize:10485760 segmentSchedule:0 \* \* \* \* \* defaultAudioSearchPosition: true skipKeyFrameUntilAudioTimeout: 10000 notifyListener: null fileTemplate:${SourceStreamName}_${SegmentTime}_${SegmentNumber} fileVersionDelegate:StreamRecorderFileVersionDelegate  
> INFO server comment - RTPMediaCaster.Reconnector[508999822:live/_definst_:myStream1.stream]: done: 1

As you know from the log above, other parameters are set normally, but you can see that the file path part contains null.  
I thought **nameStr** was a unique name for streaming, but it wasn’t. I want to save files by setting different paths for each stream, but I don’t know how to get my name for each stream when I use an auto recorder!  
So ultimately, what I’m curious about is finding out each name of the streaming when using an automatic recorder.  
Before running the startRecoding function in the code above, is there a way to find out streamName?  
I’d appreciate your help.

ps. When streaming starts, receiving stream names from the onPublish method in the StreamListener class works very well.

---

<div class="post-metadata">

**Author:** ![Shemar\_Cox](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Shemar\_Cox](https://community.wowza.com/u/Shemar_Cox)\
**Post date:** [April 21, 2021, 4:42am UTC](https://community.wowza.com/t/how-to-set-the-stream-name-to-recordparams-in-auto-recorder/93186/2 "2021-04-21T04:42:39Z")

</div>

Before executing the startrecoding function of the onAppCreate function,  
I wrote additional codes and tested them, and I was able to check the values.

> appInstance.getApplication().getName(); // live  
> appInstance.getName(); // _definst_  
> appInstance.getStreams().getCount(); // 0

The result is that the onAppCreate function runs before the streams are published, so the number of streams published is zero?

If I only provide appInstance, recordParams as a factor for the entire recording, how do I get the information of the published streams before performing that action?

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [April 21, 2021, 9:17pm UTC](https://community.wowza.com/t/how-to-set-the-stream-name-to-recordparams-in-auto-recorder/93186/3 "2021-04-21T21:17:39Z")

</div>

Let me see what I can find out for you, The engineer who created that GitHub repo is out today, so I may not have an answer for you until tomorrow.

---

<div class="post-metadata">

**Author:** ![Jason\_Tuchler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/jason_tuchler/32/462_2.png) [@Jason\_Tuchler](https://community.wowza.com/u/Jason_Tuchler)\
**Post date:** [April 21, 2021, 10:24pm UTC](https://community.wowza.com/t/how-to-set-the-stream-name-to-recordparams-in-auto-recorder/93186/4 "2021-04-21T22:24:42Z")

</div>

Hello @Shemar_Cox

To set the output file name:  
recordParams.outputFile = “myFileName”;  
\*Replace myFileName with the file name of your choice.

More details here:  
[https://www.wowza.com/resources/serverapi/com/wowza/wms/livestreamrecord/manager/StreamRecorderParameters.html#outputFile](https://www.wowza.com/resources/serverapi/com/wowza/wms/livestreamrecord/manager/StreamRecorderParameters.html#outputFile)

Regards,  
JasonT

---

<div class="post-metadata">

**Author:** ![Shemar\_Cox](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Shemar\_Cox](https://community.wowza.com/u/Shemar_Cox)\
**Post date:** [April 22, 2021, 12:05am UTC](https://community.wowza.com/t/how-to-set-the-stream-name-to-recordparams-in-auto-recorder/93186/5 "2021-04-22T00:05:47Z")

</div>

Hello, Jason\_TuChler.  
First of all, thank you for your reply.

But what I meant was to generate the path to the output file by stream.

```
recordParams.outputPath = "D:/wowza/content/"+"${SourceStreamName}";
File folder = new File(recordParams.outputPath);
if(!folder.exists()) {
	folder.mkdirs();
}

```

If I write the above code, the wowza server will recognize outputPath by streaming.  
However, when creating a physical folder path, it is created as shown in the picture below because it is recognized as the text itself.

 ![cap1](https://us1.discourse-cdn.com/flex002/uploads/wowza1/original/1X/b2d519ada0b78be83fdb05a104e8da0df1668b96.png)

This is why I’m trying to get my own stream name (to create by streaming in the path).  
Passes only two variables to the startRecoding function for recording automatically for all streaming. In this case, is there any way to get a stream name? Is there only a way to designate and fill it out myself?

Since I am using a translator, my intentions may not be accurately conveyed.  
Thanks very much for your help.

---

<div class="post-metadata">

**Author:** ![Shemar\_Cox](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Shemar\_Cox](https://community.wowza.com/u/Shemar_Cox)\
**Post date:** [April 22, 2021, 5:37am UTC](https://community.wowza.com/t/how-to-set-the-stream-name-to-recordparams-in-auto-recorder/93186/6 "2021-04-22T05:37:20Z")

</div>

After hours of hard work… I wrote the code as below.

```
public void onAppStart(IApplicationInstance appInstance)
{
	getLogger().info("ModuleAutoRecordAdvancedExample onAppStart["+appInstance.getContextStr()+"]: ");

 	this.appInstance = appInstance;
 	this.vhost = appInstance.getVHost();
 	List<StartupStream> startupStreams = vhost.getStartupStreams();
 	StreamRecorderParameters recordParams = null;
 	for (StartupStream startupStream : startupStreams) {
 		recordParams = new StreamRecorderParameters(appInstance);
 		recordParams.fileFormat = IStreamRecorderConstants.FORMAT_MP4;
 		recordParams.fileTemplate = "${SourceStreamName}_${SegmentTime}_${SegmentNumber}";
 		recordParams.segmentationType = IStreamRecorderConstants.SEGMENT_BY_DURATION;
 		recordParams.segmentDuration = 60000;
 		recordParams.outputPath = "D:/wowza/content/"+startupStream.getStreamName()+"/";
 		
 		File folder = new File(recordParams.outputPath);
 		if(!folder.exists()) {
 			folder.mkdirs();
 		}
 		vhost.getLiveStreamRecordManager().startRecording(appInstance, startupStream.getStreamName(), recordParams);
		
	}
}

```

The code above calls up a list of pre-registered startupStreams, creates as many of your own folders as possible, and begins recording.

As a result of testing with two mobile cameras, the files were recorded by creating folders respectively.

Is there any improvement over the above method?  
If there is, I will refer to it if you give me an additional answer.

Thank you.
