Wowza Community

Auto recording module

Hi there,

I have a Java class with this code:

public class AutoRecordModule extends ModuleBase implements IModuleOnApp {
	private IApplicationInstance appInstance = null;
	private IVHost vhost = null;
	public void onAppStart(IApplicationInstance appInstance)
		getLogger().info("ModuleAutoRecordCustom onAppStart["+appInstance.getContextStr()+"]: ");
     	this.appInstance = appInstance;
     	this.vhost = appInstance.getVHost();
		// set recording params as desired
		StreamRecorderParameters recordParams = new StreamRecorderParameters(appInstance);
	    // don't segment, using the default content path, do not append (i.e. overwrite if file exists)
		recordParams.segmentationType = IStreamRecorderConstants.SEGMENT_NONE;
		recordParams.versioningOption = IStreamRecorderConstants.APPEND_FILE;
		recordParams.fileFormat = IStreamRecorderConstants.FORMAT_MP4;
		recordParams.startOnKeyFrame =  true;
		recordParams.recordData = true;
		getLogger().info("--- startRecording");
		// tell LiveStreamRecordManager to record all streams for this Instance using these params
		vhost.getLiveStreamRecordManager().startRecording(appInstance, recordParams);
	public void onAppStop(IApplicationInstance appInstance) {
		// TODO Auto-generated method stub

This code record all videos publiched on my app.

But I have a really wrong thing, if a video stream is unpublish it and immediately a new streams with different name is publish, the recorder module append on the old file, I mean this new video is appending on the last video file recorded and not on a new file.

Here I copy a couple of lines of my console log

INFO server comment - MyStreamRecorderListener.onSegmentEnd[live/definst]: segment closed:testrecord2

INFO server comment - MyStreamRecorderListener.onStopRecorder[live/definst]: Recording stopped:testrecord2 /usr/local/WowzaStreamingEngine/content/testrecord1.mp4

Can you help me with this please?



You might consider leveraging the functionality provided by the file version delegate:

recordParams.fileVersionDelegate = new MyFileVersionDelegate();
class MyFileVersionDelegate implements IStreamRecorderFileVersionDelegate

And further control using the IStreamRecorderActionNotify interface to specify stream specific parameters. You can take a look at the advanced recording module for a complete example.