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:


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{ 
		public void onLiveStreamDvrRecorderCreate(
				ILiveStreamDvrRecorder recorder, String streamName) {
                        // simply rename the recording as follows when the recorder is created:

		public void onLiveStreamDvrRecorderDestroy(
				ILiveStreamDvrRecorder recorder) {

		public void onLiveStreamDvrRecorderInit(
				ILiveStreamDvrRecorder recorder, String streamName) {
	class DVREnabler implements ILiveStreamDvrRecorderControl{ 
		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.