Try to use REST API to start and stop recording from a live stream

Hi,

I’m trying to build a web application that could start and stop recording from a Wowza stream through the REST API that wowza provides. First, I can retrieve the list of instances that are currently recording

% curl http://192.168.1.126:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders
<?xml version="1.0" encoding="UTF-8" ?>
<StreamRecorders restURI="http://192.168.1.126:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders">
  <InstanceName></InstanceName>
  <streamRecorders restURI="/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances//streamrecorders/m.stream">
    <RecorderName>m.stream</RecorderName>
    <InstanceName></InstanceName>
    <RecorderState>Recording in Progress</RecorderState>
    <DefaultRecorder>false</DefaultRecorder>
    <SegmentationType>None</SegmentationType>
    <OutputPath>C:\Program Files (x86)\Wowza Media Systems\Wowza Streaming Engine 4.1.2\content</OutputPath>
    <BaseFile>2m.stream.mp4</BaseFile>
    <FileFormat>MP4</FileFormat>
    <FileVersionDelegate>com.wowza.wms.livestreamrecord.manager.StreamRecorderFileVersionDelegate</FileVersionDelegate>
    <FileTemplate>${SourceStreamName}_${RecordingStartTime}_${SegmentNumber}</FileTemplate>
    <SegmentDuration>832632</SegmentDuration>
    <SegmentSize>10485760</SegmentSize>
    <SegmentSchedule>0 1 * * * *</SegmentSchedule>
    <RecordData>false</RecordData>
    <StartOnKeyFrame>true</StartOnKeyFrame>
    <Option>Overwrite existing file</Option>
    <MoveFirstVideoFrameToZero>true</MoveFirstVideoFrameToZero>
    <CurrentSize>291399785</CurrentSize>
    <CurrentDuration>832632</CurrentDuration>
    <CurrentFile>C:\Program Files (x86)\Wowza Media Systems\Wowza Streaming Engine 4.1.2\content\2m.stream.mp4</CurrentFile>
    <RecordingStartTime>2015-07-03-10.00.50.491-EDT</RecordingStartTime>
  </streamRecorders>
</StreamRecorders>% 

Now, I am trying to start and stop new recording with the API. Starting a recording does not work:

curl -X POST http://admin:admin@192.168.1.126:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <error>
    <wowzaServer>4.2.0</wowzaServer>
    <code>500</code>
    <message>The server encountered an unexpected condition which prevented it from fulfilling the request</message>
</error>

Neither does Stop recording:

curl -X PUT http://admin:admin@192.168.1.126:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders/m.stream/actions/stopRecording
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <error>
    <wowzaServer>4.2.0</wowzaServer>
    <code>500</code>
    <message>The server encountered an unexpected condition which prevented it from fulfilling the request</message>
</error>

This seems to happen because of a Null exception:

class com.wowza.wms.rest.vhosts.applications.instances.streamrecorders.StreamRecorderConfig.post : java.lang.NullPointerException
  |at com.wowza.wms.rest.ConfigBase.getObject(Unknown Source)
  |at com.wowza.wms.rest.ConfigBase.post(Unknown Source)
  |at com.wowza.wms.rest.ConfigBase.post(Unknown Source)
  |at org.restlet.resource.ServerResource.doHandle(ServerResource.java:454)
  |at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:683)|

Even though the path says otherwise, the version of Wowza I’m trying this on is Engine Version 4.2.0 (build 15089)

Hi,

This will be handled in the ticket that you created (133384).

Regards,

Jason

I just had a similar issue , REST API Recording doesnt work , checking if you found any solutions so far .

Hi,

You could try something like the following to instigate a recording of an existing live stream,

curl -X POST --header 'Accept:application/json; charset=utf-8' --header 'Content-type:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders/myStream -d '
{
 "restURI":"http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/streamrecorders/myStream",
 "recorderName":"myStream",
"instanceName":"_definst_",
"recorderState":"Waiting for stream",
"defaultRecorder":true,
"segmentationType":"None",
"outputPath":"/usr/local/WowzaStreamingEngine/content",
"baseFile":"myrecord2.mp4",
"fileFormat":"MP4",
"fileVersionDelegateName":"com.wowza.wms.livestreamrecord.manager.StreamRecorderFileVersionDelegate",
"fileTemplate":"${BaseFileName}_${RecordingStartTime}_${SegmentNumber}",
"segmentDuration":900000,
"segmentSize":10485760,
"segmentSchedule":"0 * * * * *",
"recordData":true,
"startOnKeyFrame":true,
"option":"Version existing file",
"moveFirstVideoFrameToZero":true,
"currentSize":0,
"currentDuration":0,
"recordingStartTime":""
}'

(replacing app, stream name, path etc accordingly).

More details can be found here

Paul

if its not a secret can we also please learn the solution @Jason Hilton

im having the same issue