Flussonic Media Server documentation

DVR API

Configuring DVR on a stream Anchor Anchor x2

You need to send admin login/password and pass text representation of Flussonic config file:

curl -u flussonic:pass --data 'stream ort { dvr /storage 2d; }' http://192.168.2.3:8080/flussonic/api/modify_config

Also you should take a look at SQL API with possibility to create DVR on a stream with SQL.

You can use the same call to modify configuration of DVR:

curl -u flussonic:pass --data 'stream ort { dvr_offline /storage 20d; }' http://192.168.2.3:8080/flussonic/api/modify_config

Stop DVR recording Anchor Anchor x2

curl -u flussonic:pass --data '' http://192.168.2.3:8080/flussonic/api/dvr_disable/ort

This stops recording DVR on a running stream ort. If stream will be restarted, it will continue recording DVR.

Start DVR recording Anchor Anchor x2

curl -u flussonic:pass --data '' http://192.168.2.3:8080/flussonic/api/dvr_enable/ort

This starts recording DVR on a running stream ort. If stream was configured as dvr_offline or api call dvr_disable was called before, this call will enable recording. If stream will be restarted, its recording status will switch to default specified in config.

DVR Lock Anchor Anchor x2

You can lock record to revert autodelete it from archive. This can be useful for the organization user nPVR or save important records.

curl -u flussonic:letmein! --data '{"stream":"ort","from":1483971680,"duration":1000}' http://192.168.2.3:8080/flussonic/api/dvr/lock

Where:

  • 1483971680 — start time in unix time;
  • 1000 — duration in seconds.

You can request locks from API using URL like this:

curl http://192.168.2.3:8080/ort/recording_status.json?from=1483970680\&to=now\&request=ranges,locks
[{"stream":"ort","ranges":[{"duration":3687,"from":1483970675},{"duration":56758,"from":1483974376},{"duration":332,"from":1484031143}],"locks":[{"duration":1004,"from":1483971680}]}]

DVR Unlock Anchor Anchor x2

If the record is unlocked, it is automatically deleted according to archive cleanup settings.

curl -u flussonic:letmein! --data '{"stream":"ort","from":1483971680,"duration":1000}' http://192.168.2.3:8080/flussonic/api/dvr/unlock

Where:

  • 1483971680 — start time in unix time;
  • 1000 — duration in seconds.

Save MP4 Anchor Anchor x2

Admin is allowed to export mp4 from DVR and save it immediately on server disk without network transfer.

curl -u flussonic:letmein! --data '' http://192.168.2.3:8080/ort/save-mp4-1350274200-4200?file=/storage/recording1.mp4

Where:

  • 1483971680 — start time in unix time;
  • 1000 — duration in seconds.

This will save directly to file /storage/recording1.mp4

Use this with care, you can overwrite existing file.

It is possible to pass metadata to save to mp4 file:

curl -u flussonic:letmein! --data 'some opaque value' http://192.168.2.3:8080/ort/save-mp4-1350274200-4200?file=/storage/recording1.mp4&meta=true

Opaque metadata will be stored to udta.meta.ilst.data atom

Total recorded range Anchor Anchor x2

It is possible to ask Flussonic: what is the total recorded range, where is the beginning and the end of record:
$ curl http://192.168.2.3:8080/ort/recording_status.json
{"ort":{"from":1525186456,"to":1526910900}}

All times here are UTC timestamps.

Recorded status report Anchor Anchor x2

You can ask Flussonic: what time ranges are recorded on disk:

curl -v 'http://192.168.2.3:8080/ort/recording_status.json?from=1525186456'
...
< HTTP/1.1 200 OK
...
< Server: Flussonic
< X-Route-Time: 83
< X-Run-Time: 3391
< Content-Type: application/json

[{"stream":"ort","warning":"too_big_range","ranges":[{"duration":28800,"from":1525183200},{"duration":7200,"from":1525219200},{"duration":3600,"from":1525233600},{"duration":10800,"from":1525240800},{"duration":43200,"from":1525255200},{"duration":7200,"from":1525309200},{"duration":39600,"from":1525323600},{"duration":7200,"from":1525377600},{"duration":3600,"from":1525392000},{"duration":3600,"from":1525402800}

Here you get a forced brief reply. Take a look at "warning":"too_big_range"

It happens that you do not specify force_detailed and total range from from to now is more than 4 days.

In this case Flussonic will send you some information that is not precise, but very cheap to calculate. If you still want to request a very detailed information for a very long period of time, add request force_detailed:

curl -v 'http://192.168.2.3:8080/ort/recording_status.json?from=1525186456&request=ranges,force_detailed'
...
< HTTP/1.1 200 OK
...
< Server: Flussonic
< X-Route-Time: 83
< X-Run-Time: 174210
< Content-Type: application/json

[{"stream":"ort","ranges":[{"duration":24179,"from":1525186456},{"duration":4788,"from":1525221374},{"duration":0,"from":1525236971},{"duration":131,"from":1525244207},{"duration":2018,"from":1525244378},{"duration":656,"from":1525246742},{"duration":0,"from":1525249845},{"duration":1169,"from":1525249848},{"duration":27216,"from":1525257917},{"duration":10177,"from":1525285203},{"duration":0,"from":1525296286},{"duration":151,"from":1525311266},{"duration":314,"from":1525311872},{"duration":2359,"from":1525312194},{"duration":7,"from":1525325359},{"duration":0,"from":1525328402},{"duration":533,"from":1525328405},{"duration":
...

You can see that warning disappeared but total runtime is 50 times more. The idea is that you usually do not need to have a precise information about contigious recorded periods when you request several days and more.

If you want to draw a timeline, then on 1920px wide screen, duration of week means that 1 pixel is responsible for about 5 minutes. One hour will be about 10-11 pixels wide. No need to spend 50 time more on server to draw UI more precise in these 10 pixels.

If you request short duration, it will be easier:

curl -v 'http://192.168.2.3:8080/ort/recording_status.json?from=1525186456&to=1525272856&request=ranges'
...
< HTTP/1.1 200 OK
...
< Server: Flussonic
< X-Route-Time: 83
< X-Run-Time: 20723
< Content-Type: application/json

[{"stream":"ort","ranges":[{"duration":24179,"from":1525186456},{"duration":4788,"from":1525221374},{"duration":0,"from":1525236971},{"duration":131,"from":1525244207},{"duration":2018,"from":1525244378},{"duration":656,"from":1525246742},{"duration":0,"from":1525249845},{"duration":1169,"from":1525249848},{"duration":14941,"from":1525257917}]}]

It takes more time than brief information, but less than full request.

You can specify following requests in request option:

  • ranges — list of contigious recorded periods in DVR. This information may change if your Flussonic is right now replicating information from some source
  • brief_thumbnails — list of UTC of some screenshots, saved in DVR. Not recommended to use anymore
  • force_detailed — force sending explicit and precise information even on very wide time range
  • hour_bitmap — send brief recorded information as a large string with bit mask of recorded hours. Not working if ranges is specified. It is the most compact way to fetch estimate DVR information
  • locks — ask list of DVR locks

Motion detector marks Anchor Anchor x2

Motion detector marks start and end time of an event received. You can request these marks from API using recording_status.json with parameter request=motion_log:

curl http://192.168.2.3:8080/cam_office/recording_status.json?from=1528144663&to=1528148263&request=motion_log
[{"stream":"cam10","motion_log":[{"data":{"duration":42,"start":1528145203},"subtype":"range","type":"motion"}]}]

from and to parameters specify time limits you are interested in

motion_log can be also combined with other request options using comma

Ask for JPEG screenshot Anchor Anchor x2

If you have configured thumbnails on your DVR or http thumbnails, then you can ask Flussonic to show.

Flussonic can autocorrect your request when you do not know exact url of thumbnail. When you have fetched ranges from previous call, just point your browser to url, calculated from UTC.

For example 1525244378 is translated to 2018/05/02/06/59/38, so:

curl -v 'http://192.168.2.3:8080/ort/2018/05/02/06/59/38.jpg'
...
< HTTP/1.1 302 Found
< Location: /ort/2018/05/02/07/00/40.jpg

curl -v 'http://192.168.2.3:8080/ort/2018/05/02/07/00/40.jpg'
...
< HTTP/1.1 200 OK
...
< Content-Length: 5738
< Content-Type: image/jpeg
< Last-Modified: Wed, 02-May-2018 07:00:40 GMT
< X-Thumbnail-Utc: 1525244440
...here goes jpeg...

Ondemand generate JPEG screenshot Anchor Anchor x2

It is possible to ask Flussonic to generate JPEG on-fly. It can reduce disk space, disk IO on write, but be careful and protect it with authorization because it is not cheap for CPU:

curl -v 'http://192.168.2.3:8080/ort/2018/05/02/07/00/40-preview.jpg'
...
< HTTP/1.1 200 OK
...
< Content-Length: 5738
< Content-Type: image/jpeg
< Last-Modified: Wed, 02-May-2018 07:00:40 GMT
< X-Thumbnail-Utc: 1525244440
...here goes jpeg...

MP4 video screenshot Anchor Anchor x2

We recommend to refuse from JPEG screenshots and use our video thumbnails

curl -v 'http://192.168.2.3:8080/ort/2018/05/02/06/59/38-preview.mp4'
...
< HTTP/1.1 302 Found
< Location: /ort/2018/05/02/07/00/40-preview.mp4

curl -v 'http://192.168.2.3:8080/ort/2018/05/02/07/00/40-preview.mp4'
...
< HTTP/1.1 200 OK
...
< Content-Length: 8756
< Content-Type: vide/mp4
< Last-Modified: Wed, 02-May-2018 07:00:40 GMT
< X-Thumbnail-Utc: 1525244440
...here goes jpeg...

You will receive mp4 with one keyframe

Export part of MP4 Anchor Anchor x2

Ask Flussonic to send DVR as mp4:

curl -v http://192.168.2.3:8080/ort/archive-1525186456-3600.mp4
...
< HTTP/1.1 200 OK
< Content-Type: video/mp4
< X-Session: a666873ba918d02f81f9b39e336906d85bdbac20
< Content-Disposition: attachment; filename=ort_1525186456_3600.mp4
..
< X-Prepare-Percent: 70
< X-Prepare-Percent: 80
< Content-Length: 81773187
< X-Prepare-Time: 27487

...here goes big mp4...