How to initiate stream specific DVR capabilities and rename the recording

This article demonstrates how to initiate stream specific DVR onpublish and rename the nDVR recording.

First, ensure you setup your nDVR configuration. You will want to turn on the dvr packetizer and initiate nDVR but include the startRecordingOnStartup property to stop it from recording by default.

Your configuration within the Application.xml under Root/Application:
 

<DVR>
<Recorders>dvrrecorder</Recorders>
<Store>dvrfilestorage</Store>
<WindowDuration>0</WindowDuration>
<StorageDir>${com.wowza.wms.context.VHostConfigHome}/dvr</StorageDir>
<ArchiveStrategy>append</ArchiveStrategy>
<Properties>
<Property>
<Name>startRecordingOnStartup</Name>
<Value>false</Value>
<Type>boolean</Type>
</Property>
</Properties>
</DVR>

Thereafter, you need a small bit of code to handle the control and file renaming aspects. You’ll leverage the ILiveStreamDvrRecorderActionNotify and ILiveStreamDvrRecorderControl accordingly:

public class DVRInitiateRecording extends ModuleBase{    
	public void onAppStart(IApplicationInstance appInstance) {  
                // setup your event handlers
		appInstance.setLiveStreamDvrRecorderControl(new DVREnabler());
		appInstance.addDvrRecorderListener(new DVRRecorderActions());
	}
	
	class DVRRecorderActions implements ILiveStreamDvrRecorderActionNotify{ 
		@Override
		public void onLiveStreamDvrRecorderCreate(
				ILiveStreamDvrRecorder recorder, String streamName) {
                        // simply rename the recording as follows when the recorder is created:
			recorder.setRecordingName(streamName+"_recordme");  
		}

		@Override
		public void onLiveStreamDvrRecorderDestroy(
				ILiveStreamDvrRecorder recorder) {
		}

		@Override
		public void onLiveStreamDvrRecorderInit(
				ILiveStreamDvrRecorder recorder, String streamName) {
		} 
	}
	
	class DVREnabler implements ILiveStreamDvrRecorderControl{ 
		@Override
		public boolean shouldDvrRecord(String recorderName, IMediaStream stream) { 
                        /// Here if you only want to record specific streams, make the determination
                        ///  ex. if(stream.getName().equalsIgnoreCase("Stream")){ ... }  
                        /// You could read from properties list in Application.xml to determine valid streams etc.
			return true;
		} 
	} 
}

Comments are closed.