# How can I record a stream programmatically?

**URL:** <https://community.wowza.com/t/how-can-i-record-a-stream-programmatically/47225>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [June 28, 2016, 10:56am UTC](https://community.wowza.com/t/how-can-i-record-a-stream-programmatically/47225 "2016-06-28T10:56:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grant\_Curtis](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@Grant\_Curtis](https://community.wowza.com/u/Grant_Curtis)\
**Post date:** [June 28, 2016, 10:56am UTC](https://community.wowza.com/t/how-can-i-record-a-stream-programmatically/47225/1 "2016-06-28T10:56:55Z")

</div>

I have an IStreamRecorderActionNotify implementation:

```auto
class StreamRecorderListener implements IStreamRecorderActionNotify
{
	IApplicationInstance appInstance;
	StreamRecorderListener(IApplicationInstance appInstance) {
		this.appInstance = appInstance;
	}
	@Override
	public void onCreateRecorder(IStreamRecorder recorder)
	{
		WMSLoggerFactory.getLogger(StreamRecorderListener.class).info("MyStreamRecorderListener.onCreateRecorder[" + appInstance.getContextStr() + "]: new Recording created:" + recorder.getStreamName());
	}
	@Override
	public void onStartRecorder(IStreamRecorder recorder)
	{
	    // log where the recording is going to being written
		WMSLoggerFactory.getLogger(StreamRecorderListener.class).info("MyStreamRecorderListener.onStartRecorder[" + appInstance.getContextStr() + "]: new Recording started:" + recorder.getStreamName() + " " + recorder.getFilePath());
	}

```

After running this code:

```auto
public void triggerRecording(String channel){
		try{
			if(!isRecording){
				getLogger().info("Starting record");
				StreamRecorderParameters recordParams = setRecordParams();
		 		vhost.getLiveStreamRecordManager().startRecording(appInstance, channel, recordParams);
		 		isRecording = true;
			}
		}catch(Exception e){
			getLogger().error(e);
		}
	}

```

I get this in the logs:

```auto
MyStreamRecorderListener.onCreateRecorder[live/_definst_]: new Recording created:cumin

```

triggered by StreamRecorderListener.java onCreateRecorder.

I would expect that onStartRecorder gets called as well, but this function is never hit. Am I missing something?

These are how I set my record params:

```auto
	private StreamRecorderParameters setRecordParams(){
		StreamRecorderParameters recordParams = new StreamRecorderParameters(appInstance);
 		recordParams.segmentationType = IStreamRecorderConstants.SEGMENT_NONE;
 		recordParams.versioningOption = IStreamRecorderConstants.OVERWRITE_FILE;
 		recordParams.fileFormat = IStreamRecorderConstants.FORMAT_MP4;
 		recordParams.startOnKeyFrame = true;
 		recordParams.recordData = true;
 		recordParams.fileVersionDelegate = new FileVersionDelegate();
 		recordParams.notifyListener = new StreamRecorderListener(appInstance);
 		return recordParams;
	}

```

---

<div class="post-metadata">

**Author:** ![Michelle\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/michelle_b/32/394_2.png) [@Michelle\_B](https://community.wowza.com/u/Michelle_B)\
**Post date:** [August 9, 2016, 9:57pm UTC](https://community.wowza.com/t/how-can-i-record-a-stream-programmatically/47225/2 "2016-08-09T21:57:33Z")

</div>

Hi,

Do you get the same issue when using our [example module](https://www.wowza.com/docs/how-to-start-and-stop-live-stream-recordings-programmatically-livestreamrecordautorecord-example%28LiveStreamRecordAutoRecord-example%29)? How are you calling the triggerRecording method?

Michelle
