Skip to main content
Skip table of contents

Update cаmera settings: Camera.Update

The method and parameters

The method updates the settings for the specified cameras.

string Camera.Update (uid camera, StreamsObject streams, OnvifObject onvif)

Parameters

uid camera REQUIRED = camera-uid5065687 – a unique camera identifier within the installation.


StreamsObject streams – sets stream parameters for a camera.

object StreamsObject

AccessObjectstreams.camera-uid5065687-primary.access– specifies the permission access level to Live and DVR.


enumstreams.camera-uid5065687-primary.access.allow=private– the parameter specifies the type of access.


stringstreams.camera-uid5065687-primary.access.password=admin – the password for authorization.


stringstreams.camera-uid5065687-primary.access.user=admin – the name of the authorization user.


arraystreams.camera-uid5065687-primary.access.whitelist=[]  the list of IP4\IP6 addresses from which access is allowed without authorization.


uidstreams.camera-uid5065687-primary.camera = camera-uid5065687– sets a unique camera identifier.


ClusterObjectstreams.camera-uid5065687-primary.cluster – the configuration of the stream capture in fault-tolerant mode.


stringstreams.camera-uid5065687-primary.cluster.primary – the hostname of the cluster primary node that constantly captures a stream.



DvrObject streams.camera-uid5065687-primary.dvr– defines the parameters of recording and archive storage for a stream.


bytesstreams.camera-uid5065687-primary.dvr.buffer=1M– the size of the internal buffer for caching read and write operations. A larger size reduces the number of disk accesses but increases RAM consumption.


secondsstreams.camera-uid5065687-primary.dvr.duration=1d– specifies the DVR storage period in seconds. Once this time is over, the archive will be automatically cleaned. The storage period can be adjusted both upwards and downwards.

The following abbreviations can be used in this context: d – days (example:30d), h – hours (example:120h), m – minutes (example: 20m).


boolstreams.camera-uid5065687-primary.dvr.enable=false– defines if DVR recording is allowed. By default, it is false– not allowed.


stringstreams.camera-uid5065687-primary.dvr.locationREQUIREDfile:///storage/– when DVR recording is enabled, this parameter is required and defines the archive storage location.


bytesstreams.camera-uid5065687-primary.dvr.quota = 0G– sets the archive storage volume limit. If the parameter isn’t specified or equals 0, the storage volume is unlimited.

The following abbreviations can be used in this context: G – gigabyte (example: 30G), M – megabyte (example: 120M), K – kilobyte (example: 20K).

In the current version, this parameter doesn't limit disk usage. When calling the API, this parameter can be used as a reference but doesn’t enforce any physical disk space constraints.


boolstreams.camera-uid5065687-primary.enable=true – whether the camera is allowed or not.


ReconnectParamsstreams.camera-uid5065687-primary.reconnect – parameters for reconnecting to a stream upon network loss or disconnect.


numberstreams.camera-uid5065687-primary.reconnect.interval =10 – a minimum timeout in seconds between attempts to connect to the camera stream.


numberstreams.camera-uid5065687-primary.reconnect.period=1800– a maximum time interval after which a connection to the camera will be attempted in case of consecutive failed reconnection attempts.


numberstreams.camera-uid5065687-primary.reconnect.total=500– a number of consecutive failed connection attempts, after which the Mediaserver will stop retrying and mark the stream as invalid.


urlstreams.camera-uid5065687-primary.source = rtsp://admin:admin@192.168.19.192:554/av0_0 – RTSP URL of a stream.


uidstreams.camera-uid5065687-primary.stream REQUIRED=camera-uid5065687-primary– a unique stream identifier within the installation.


arraystreams.camera-uid5065687-primary.tracks=["audio","video"]– the list of media streams to capture. If it’s not specified, the video stream will be captured.

  • video – capture the stream with video data. Will be constantly captured regardless the settings. Supports H.264 and H.265 codecs.

  • audio – capture the audio stream. If there is no stream in the initial RTSP, the stream won’t be created and captured. Supports the following codecs: PCMU, PCMA, MPA, AAC.

  • application – capture the metadata stream. Supports ONVIF.


OnvifObjectonvif – sets the ONVIF parameters for a camera.

object OnvifObject

EventObjectonvif.events – the event handlers.


stringonvif.events.MotionAlarm=dvr|live|capture|publish the list of the MotionAlarm event handlers.


stringonvif.events.PowerAlarm=dvr|publish– – the list of the PowerAlarm event handlers.


urlonvif.hostname=192.168.19.192 – an address.



POST /api/

JSON-RPC
JSON
{
    "jsonrpc": "2.0",
    "method": "Camera.Update",
    "params": {
        "camera": "camera-uid5065687",
        "streams": {
            "camera-uid5065687-primary": {
                "access": {
                    "allow": "private",
                    "password": "admin",
                    "user": "admin",
                    "whitelist": []
                },
                "camera": "camera-uid5065687",
                "cluster": {
                    "primary": "string"
                },
                "reconnect": {
                    "interval": 10,
                    "period": 1800,
                    "total": 500
                },
                "dvr": {
                    "enable": true,
                    "location": "file:///storage/",
                    "duration": "1d",
                    "buffer": "1M",
                    "quota": "0G"
                },
                "enable": true,
                "source": "rtsp://admin:admin@192.168.19.192:554/av0_0",
                "stream": "camera-uid5065687-primary",
                "tracks": [
                    "audio",
                    "video"
                ]
            }
        },
        "onvif": {
            "hostname": "192.168.19.192",
            "events": {
                "MotionAlarm": "dvr|live|capture|publish",
                "PowerAlarm": "dvr|publish"
            }
        }
    },
    "id": 1
}
cURL
BASH
curl -k --request POST \
	--url 'https://your-domain/api/' \
	--header 'Content-Length: 1425' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--header 'Authorization: Bearer <api-authorization-token>' \
	--header 'Content-Length: <Content-Length>' \
	--data '{
    "jsonrpc": "2.0",
    "method": "Camera.Update",
    "params": {
        "camera": "camera-uid5065687",
        "streams": {
            "camera-uid5065687-primary": {
                "access": {
                    "allow": "private",
                    "password": "admin",
                    "user": "admin",
                    "whitelist": []
                },
                "camera": "camera-uid5065687",
                "cluster": {
                    "primary": "string"
                },
                "reconnect": {
                    "interval": 10,
                    "period": 1800,
                    "total": 500
                },
                "dvr": {
                    "enable": true,
                    "location": "file:///storage/",
                    "duration": "1d",
                    "buffer": "1M",
                    "quota": "0G"
                },
                "enable": true,
                "source": "rtsp://admin:admin@192.168.19.192:554/av0_0",
                "stream": "camera-uid5065687-primary",
                "tracks": [
                    "audio",
                    "video"
                ]
            }
        },
        "onvif": {
            "hostname": "192.168.19.192",
            "events": {
                "MotionAlarm": "dvr|live|capture|publish",
                "PowerAlarm": "dvr|publish"
            }
        }
    },
    "id": 1
}'
PHP
PHP
$data = array (
  'jsonrpc' => '2.0',
  'method' => 'Camera.Update',
  'params' => 
  array (
    'camera' => 'camera-uid5065687',
    'streams' => 
    array (
      'camera-uid5065687-primary' => 
      array (
        'access' => 
        array (
          'allow' => 'private',
          'password' => 'admin',
          'user' => 'admin',
          'whitelist' => 
          array (
          ),
        ),
        'camera' => 'camera-uid5065687',
        'cluster' => 
        array (
          'primary' => 'string',
        ),
        'reconnect' => 
        array (
          'interval' => 10,
          'period' => 1800,
          'total' => 500,
        ),
        'dvr' => 
        array (
          'enable' => true,
          'location' => 'file:///storage/',
          'duration' => '1d',
          'buffer' => '1M',
          'quota' => '0G',
        ),
        'enable' => true,
        'source' => 'rtsp://admin:admin@192.168.19.192:554/av0_0',
        'stream' => 'camera-uid5065687-primary',
        'tracks' => 
        array (
          0 => 'audio',
          1 => 'video',
        ),
      ),
    ),
    'onvif' => 
    array (
      'hostname' => '192.168.19.192',
      'events' => 
      array (
        'MotionAlarm' => 'dvr|live|capture|publish',
        'PowerAlarm' => 'dvr|publish',
      ),
    ),
  ),
  'id' => 1,
);
$context = stream_context_create([
	'ssl'=>['verify_peer' => false],
	'http' => [
		'method' => 'POST',
		'header' => "Content-Type: application/json\r
Accept: application/json\r
Authorization: Bearer <api-authorization-token>\r
Content-Length: <Content Length>",
		'content'=>json_encode($data)
	]
]);
$result = file_get_contents('https://your-domain/api/', false, $context);

200 OK

The UID of an added stream

JSON
"<stream-uid>"

400 Bad Request

A JSON-RPC error

JSON
{
    "error": {
        "code": -32601,
        "message": "Method not found"
    }
}

500 Internal Server Error

A server error

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.