Wowza Community

How to set the stream name to recordParams in Auto Recorder

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

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.

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?

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.

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

Regards,
JasonT

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

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.

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.