Updаte a stream for a camera: Stream.Update
The method and parameters
The Stream.Update
method changes stream settings for specified cameras.
string Stream.Update
(uid camera
, StreamsObject streams
)
The parameters
uid camera
REQUIRED = camera-uid5065687
– a uniques camera identifier within the installation.
StreamsObject
streams – sets the stream parameters for a camera.
object StreamsObject
AccessObject streams.camera-uid5065687-primary.access
–specifies the permission access level to Live and DVR.
enum streams.camera-uid5065687-primary.access.allow
= private
– the parameter specifies the type of access.
string streams.camera-uid5065687-primary.access.password
= admin
– the password for authorization.
string streams.camera-uid5065687-primary.access.user
= admin
– the name of the authorization user.
array streams.camera-uid5065687-primary.access.whitelist
= []
– the list of IP4\IP6 addresses from which access is allowed without authorization.
uid streams.camera-uid5065687-primary.camera
= camera-uid5065687
– sets a unique camera identifier.
ClusterObject streams.camera-uid5065687-primary.cluster
–the configuration of the stream capture in fault-tolerant mode.
string streams.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.
seconds streams.camera-uid5065687-primary.dvr.duration
= 1d
– specifies the DVR storage period in seconds. After this period expires, older recordings are automatically deleted, ensuring continuous storage of new data. 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
).
bool streams.camera-uid5065687-primary.dvr.enable
= false
– defines if DVR recording is allowed. By default, it is false
– not allowed.
string streams.camera-uid5065687-primary.dvr.location
REQUIRED =file:///storage/
– when DVR recording is enabled, this parameter is required and defines the archive storage location.
bytes streams.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.
bool streams.camera-uid5065687-primary.enable
= true
– whether the camera is allowed.
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.
number streams.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
.
url streams.camera-uid5065687-primary.source
= rtsp://admin:admin@192.168.19.192:554/av0_0
– RTSP URL of a stream.
uid streams.camera-uid5065687-primary.stream
REQUIRED =camera-uid5065687-primary
– a unique stream identifier within the installation.
array streams.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.
POST /api/ |
JSON-RPC
{
"jsonrpc": "2.0",
"method": "Stream.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"
]
}
}
},
"id": 1
}
cURL
curl -k --request POST \
--url 'https://your-domain/api/' \
--header 'Content-Length: 1212' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <api-authorization-token>' \
--header 'Content-Length: <data length>' \
--data '{
"jsonrpc": "2.0",
"method": "Stream.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"
]
}
}
},
"id": 1
}'
PHP
$data = array (
'jsonrpc' => '2.0',
'method' => 'Stream.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',
),
),
),
),
'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: <data lenth>",
'content'=>json_encode($data)
]
]);
$result = file_get_contents('https://your-domain/api/', false, $context);
200 |
UID of an added stream
JSON
|
400 |
The JSON-RPC error
JSON
|
500 |
The server error |