# Create and manage stream recorders You can use the Wowza Streaming Engine™ media server software REST API to create and manage stream recorders in a Wowza Streaming Engine instance. A stream recorder creates an MP4 recording of a stream as it's broadcast from a live application. A recorder can be created before the live application starts streaming, or while the live application is actually streaming. You can use the REST API to stop a recorder at any time; otherwise, it stops when the server no longer receives the incoming stream. After the recorder stops, it is no longer available — the MP4 recording is saved, but you have to create a new recorder if you plan to restart and record the same live application. > **Notes:** - Wowza Streaming Engine 4.3.0 or later is required. - PHP examples for the tasks in this article are available in the **tests** folder of the [PHP REST Library for Wowza Streaming Engine on GitHub](https://github.com/WowzaMediaSystems/wse-rest-library-php). ## Get a list of recorders View a list of all stream recorders for an application on a local Wowza Streaming Engine instance: ```bash curl -X GET \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/instances/{instanceName}/streamrecorders ``` In this example, retrieve a list of all stream recorders for an application named *testlive*: ```bash curl -X GET \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/instances/{instanceName}/streamrecorders ``` If the stream and recording haven't started, the command should return a response that looks something like this: ```json { "serverName": "serverName", "instanceName": "instanceName", "streamrecorder": [{ "recorderName": "myStream", "instanceName": "instanceName", "recorderState": "Waiting for stream", "defaultRecorder": false, "segmentationType": "None", "outputPath": "", "baseFile": ".mp4", "fileFormat": "MP4", "fileVersionDelegateName": "com.wowza.wms.livestreamrecord.manager.StreamRecorderFileVersionDelegate", "fileTemplate": "${BaseFileName}_${RecordingStartTime}_${SegmentNumber}", "segmentDuration": 900000, "segmentSize": 10485760, "segmentSchedule": "0 * * * * *", "recordData": false, "startOnKeyFrame": true, "splitOnTcDiscontinuity": false, "backBufferTime": 0, "option": "Version existing file", "moveFirstVideoFrameToZero": true, "currentSize": 0, "currentDuration": 0, "recordingStartTime": "" }] } ``` If the stream and recorder have started, the response looks something like this: ```json { "serverName": "serverName", "instanceName": "instanceName", "streamrecorder": [{ "recorderName": "myStream", "instanceName": "instanceName", "recorderState": "Recording in Progress", "defaultRecorder": false, "segmentationType": "None", "outputPath": "", "baseFile": "myStream.mp4", "fileFormat": "MP4", "fileVersionDelegateName": "com.wowza.wms.livestreamrecord.manager.StreamRecorderFileVersionDelegate", "fileTemplate": "${BaseFileName}_${RecordingStartTime}_${SegmentNumber}", "segmentDuration": 38537, "segmentSize": 10485760, "segmentSchedule": "0 * * * * *", "recordData": false, "startOnKeyFrame": true, "splitOnTcDiscontinuity": false, "backBufferTime": 0, "option": "Version existing file", "moveFirstVideoFrameToZero": true, "currentSize": 3104321, "currentDuration": 38537, "currentFile": "/Library/WowzaStreamingEngine/content/myStream_2017-04-06-16.07.01.033-PDT_0.mp4", "recordingStartTime": "2017-04-06-16.07.01.033--07:00" }] } ``` ## Create a recorder When you create a recorder, it starts immediately if the stream is running. Otherwise, it starts when you start the stream. Create a stream recorder named *myStream* using the default settings. Note that the stream recorder name matches the incoming stream name and is included in both the request URL and the body of the request — these must match: ```bash curl -X POST \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/instances/{instanceName}/streamrecorders/myStream \ -d '{ "instanceName": "", "fileVersionDelegateName": "", "serverName": "", "recorderName": "myStream", "currentSize": 0, "segmentSchedule": "", "startOnKeyFrame": true, "outputPath": "", "currentFile": "", "recordData": false, "applicationName": "", "moveFirstVideoFrameToZero": false, "recorderErrorString": "", "segmentSize": 0, "defaultRecorder": false, "splitOnTcDiscontinuity": false, "version": "", "baseFile": "", "segmentDuration": 0, "recordingStartTime": "", "fileTemplate": "", "backBufferTime": 0, "segmentationType": "", "currentDuration": 0, "fileFormat": "", "recorderState": "", "option": "" }' ``` The command should return a response that looks something like this: ```json { "success": true, "message": "Recorder Created", "data": null } ``` ## Split an active recording When you split, or segment, an active recording, the recorder keeps running but the current recording ends and a new recording begins from the moment of the split. Both recordings are stored in the specified `output_path` (by default, `/Library/WowzaStreamingEngine/content`) and are named according to the file naming template (by default, `[BaseFilename]_[RecordingStartTime]_[SegmentNumber].mp4`). Split a recording: ```bash curl -X PUT \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/instances/{instanceName}/streamrecorders/{recorderName}/actions/splitRecording ``` The command should return a response that looks something like this: ```json { "success": true, "message": "Recording (myStream) split", "data": null } ``` ## Stop a recording Stop a recording: ```bash curl -X PUT \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/instances/{instanceName}/streamrecorders/{recorderName}/actions/stopRecording ``` The command should return a response that looks something like this: ```json { "success": true, "message": "Recording (recorderName) stopped", "data": null } ```