Breadcrumbs

Calculate the server parameters: Server.Calculate

The method and parameters

The Server.Calculate method allows you to obtain an approximate estimate of the DVR storage size and video stream bandwidth for the specified characteristics.

The calculations provided in this documentation section are for general guidance only. Actual performance may vary depending on the configuration and model of the equipment used.

object Stream.Calculate(widthheightcodecfps, hoursdaysaudioqualitycomplexitymovement)

Параметры

number width  required – the video stream image width.


number height  required – the video stream image height.


enum codec  required – the codec used for calculation. One of the following values is available: H.264, H.265, MPEG4, MJPEG, RAW.


enum quality = average – the expected compression quality of the codec being used. One of the following values is acceptable:

  • high – high compression quality.

  • good – good compression quality

  • average – average compression quality, used when no other value is specified.

  • low – compression quality below average or low.


enum complexity = low – estimated scene complexity, how much the image changes. One of the following values is allowed:

  • low – minor scene change (less than 33% of the scene changes).

  • average – average(~50% of the scene changes).

  • above-average – above-average scene change (up to 75% of the scene changes).

  • high – intense scene change (85% or more).


enum movement = low – anticipated scene dynamics, presence of moving objects. One of the following values is allowed:

  • very-low – minimal or no movement (up to 15%).

  • low – slight movement (up to 30%).

  • average – noticeable movement (up to 50%).

  • above-average – significant movement in the video stream (up to 60%).

  • constant – continuous movement present.


number fps = 15 – the number of frames per second.


number hours = 24 – the number of DVR recording hours per day.


number days = 7 – the number of days of DVR recording and storage.


bool audio = false – presence of video in the audio stream.

POST  /api/

JSON-RPC
JSON
{
    "jsonrpc": "2.0",
    "method": "Stream.Calculate",
    "params": {
        "width": 0,
        "height": 0,
        "codec": "enum",
        "fps": 15,
        "hours": 24,
        "days": 7,
        "audio": true,
        "quality": "average",
        "complexity": "low",
        "movement": "low"
    },
    "id": 1
}
cURL
Bash
curl -k --request POST \
	--url 'https://your-domain/api/' \
	--header 'Content-Length: 327' \
	--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.Calculate",
    "params": {
        "width": 0,
        "height": 0,
        "codec": "enum",
        "fps": 15,
        "hours": 24,
        "days": 7,
        "audio": true,
        "quality": "average",
        "complexity": "low",
        "movement": "low"
    },
    "id": 1
}'
PHP
PHP
$data = array (
  'jsonrpc' => '2.0',
  'method' => 'Stream.Calculate',
  'params' => 
  array (
    'width' => 0,
    'height' => 0,
    'codec' => 'enum',
    'fps' => 15,
    'hours' => 24,
    'days' => 7,
    'audio' => true,
    'quality' => 'average',
    'complexity' => 'low',
    'movement' => 'low',
  ),
  '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 length>",
		'content'=>json_encode($data)
	]
]);
$result = file_get_contents('https://your-domain/api/', false, $context);

200  OK

The object and its characterisitics and calculated values:

  • bandwidth – bandwidth value in bits per second.

  • storage – storage capacity in bytes.

JSON
{
    "audio": false,
    "bandwidth": 2678668,
    "codec": "H.264",
    "complexity": "average",
    "days": 30,
    "fps": 20,
    "hours": 24,
    "movement": "average",
    "quality": "low",
    "resolution": "1920x1080",
    "storage": 867888542388
}

400  Bad Request

The JSON-RPC error

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

500  Internal Server Error

The server error