How to Get Video, Clips and Images

In all examples below, ACCESS_TOKEN should be replaced with an actual access token for a selected channel (camera). For watching live or recorded video it is sufficient to have an access token with “watch” permission and you will need a “full” permission access token for image and clip extraction.

Live video

Get live video URLs:

curl -X GET "https://web.vxgdemo.vxgdemo.cloud-vms.com:443/api/v4/live/watch/" -H "accept: application/json" -H "Authorization: Acc ACCESS_TOKEN

Example of a response:

{ "expire_hls": "2021-08-06T15:41:37.662355", "rtsp": "rtsp://54.172.31.247:554/live/u17m239530c239093_primary?ticket=media.eyJuIjogInUxN20yMzk1MzBjMjM5MDkzX3ByaW1hcnkifQ.1628261204.kW71CV7LPKxzWZCxUPczPDTAOK4", "hls": "https://d88wn9kkji59m.cloudfront.net:443/live/media-22/media.eyJuIjogInUxN20yMzk1MzBjMjM5MDkzX3ByaW1hcnkifQ.1628265397.RD39GS18IIRD7L8r2vqNwyPunVw/hls/u17m239530c239093_primary/index.m3u8?ticket=media.eyJuIjogInUxN20yMzk1MzBjMjM5MDkzX3ByaW1hcnkifQ.1628265397.RD39GS18IIRD7L8r2vqNwyPunVw", "expire": "2021-08-06T14:46:44.347031", "rtmp": "rtmp://54.172.31.247:1935/live/u17m239530c239093_primary?ticket=media.eyJuIjogInUxN20yMzk1MzBjMjM5MDkzX3ByaW1hcnkifQ.1628261204.kW71CV7LPKxzWZCxUPczPDTAOK4", "webrtc": { "ice_servers": [ { "urls": [ "stun:stun.l.google.com:19302" ] }, { "username": "vxgturn", "credential": "vxgturn", "urls": [ "turn:turn.vxg.io:3478?transport=udp" ] } ], "version": "2.0.2", "connection_url": "wss://webrtc-2.inst.auth2.cloud-svcp.com:443/239093/watch/08b6e083a9af4359f2f58feef045314629a2c4be/?ticket=media.eyJuIjogIjIzOTA5My93YXRjaC8wOGI2ZTA4M2E5YWY0MzU5ZjJmNThmZWVmMDQ1MzE0NjI5YTJjNGJlIn0.1628282504.eNXSKx8s6FLwoM9xrcGXLRQnbQc", "scripts": { "player": "https://web.vxgdemo.vxgdemo.cloud-vms.com:443/static/webrtc/CloudPlayer.webrtc2.js", "helpers": "https://web.vxgdemo.vxgdemo.cloud-vms.com:443/static/webrtc/CloudHelpers.js" } } }

The response contains URLs and information for connecting to the live video using the following formats:

  • RTSP

  • RTMP

  • HLS

  • WebRTC

 

Recorded video

Get Recorded video URLs:

curl -X GET "https://web.vxgdemo.vxgdemo.cloud-vms.com:443/api/v4/records/?start=2021-08-06T10%3A45%3A00&end=2021-08-06T10%3A50%3A00" -H "accept: application/json" -H "Authorization: Acc ACCESS_TOKEN

Example of a response:

The response contains links to recorded video chunks in standard MP4 format.

 

Images from recorded video

You can generate images from the recorded video for any duration and with a period that is bigger than a keyframe interval for a particular video stream. For example, you can generate images every 30 seconds for the last 12 hours. The result of this operation will be 60/30x60x12 = 1,440 JPEG images. The image resolution will be the same as the original video resolution.

  1. Start an image generation task and specify duration and interval.

Here start and end are times in UTC format, period is an image generation period in seconds.

The response will contain a task id that can be used for checking the status. It can take time if you extract images for a long duration.

  1. Check the task status.

Here 6832 is the task ID.

The response will contain the status.

  1. Retrieve the generated images.

The response will have links to JPEG images.

Images from live video

You can generate images from live video with a period that is bigger than a keyframe interval for a particular video stream. Once enabled the image generation will keep working until it is disabled.

  1. Enable or disable image generation for live video.

Here 60 is the image generation period in seconds. Set it to null to disable live image generation.

  1. Check if live image generation is enabled.

The response will contain an image generation period or null if image generation is disabled.

  1. Retrieve the generated images.

It is the same as in the previous section for images from recorded video.

Clips from recorded video

  1. Start a clip creation task:

Here start and end are times in UTC format.

The response will contain a task id that can be used for checking the task status. It can take time if you create a long clip.

  1. Check the task status and retrieve the clip.

Here 142 is the task ID.

The response will contain the status.

If the status is done then a link to a clip and a clip's thumbnail will be in the same response.