API Reference (Legacy API)
Project: Device API Documentation (New Version) | page_id: 259
Assume the device serial number is cb00a8fe73ac6e8da63ea57a1c5f4785 and the customer's remote configuration server domain is xstrive.com
Parameter Description
command command word, representing different types of operations
channel the channel number to operate on, starting from 0
value the value corresponding to the command word (some values are base64 encrypted; pay attention to the detailed API description)
auth the md5 value of username + password, must be lowercase. Assuming the username is admin and the password is admin, then userAuth = md5(“adminadmin”)
Enable or disable RTMP streaming
1. Enable RTMP push for channel 1 (command word live_control)
2. Disable RTMP push for channel 1 (command word live_control)
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/control?command=live_control&channel=0&value=stop&auth=userAuth
Note: userAuth is the md5 value of username + password. Assuming the username is admin and the password is admin, then userAuth = md5(“adminadmin”)
channel starts from 0
Enable or disable RTSP push
1. Enable RTSP push for channel 1
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/control?command=rtsp_enable_control&channel=0&value=start&auth=userAuth
2. Disable RTSP push for channel 1
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/control?command=rtsp_enable_control&channel=0&value=stop&auth=userAuth
Note: the authentication after auth is the md5-encrypted string of the username and password, for example md5(usernamepasswd)
Set the RTMP streaming address: the channel count here is assumed to be 32
1. Set the RTMP1 streaming address of channel 1
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/control?command=set_live_url&channel=0&value=base64(rtmp://xxxxx/test/stream1)&auth=userAuth
Note: the RTMP address must be base64 encrypted before being added to the request, for example base64(rtmp://xxxx/app/stream). The authentication after auth is the md5-encrypted string of the username and password, for example md5(usernamepasswd)
channel starts from 0
Set the RTSP pull address
1. Set the RTSP push address of channel 1
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/control?command=set_live_rtsp&channel=0&value=base64(rtsp://xxxx/app/test)&auth=userAuth&user=admin&pass=123456
Note: the RTSP address must be base64 encrypted before being added to the request, for example base64(rtsp://xxxx/app/stream). The authentication after auth is the md5-encrypted string of the username and password, for example md5(usernamepasswd)
user is the camera access username, pass is the camera access password
If the RTSP video stream does not require a username and password, leave them empty, for example
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/control?command=set_live_rtsp&channel=0&value=base64(rtsp://xxxx/app/test)&auth=userAuth&user=&pass=
Note: the RTSP address must not contain a username and password.
Setting example:
The video encoder account defaults to admin/admin, the IP is 192.168.0.15, the RTMP streaming address is rtmp://live.hkstv.hk.lxdns.com/live/hks1, and the RTSP pull address is rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov
auth is md5(usernamepassword), here md5(adminadmin) is f6fdffe48c908deb0f4c3bd36c032e72
RTMP address base64(rtmp://xxx), here the RTMP address is cnRtcCUzQS8vbGl2ZS5oa3N0di5oay5seGRucy5jb20vbGl2ZS9oa3Mx
RTSP address base64(rtsp://xxx), here the RTSP address is cnRzcCUzQS8vMTg0LjcyLjIzOS4xNDkvdm9kL21wNCUzQS8vQmlnQnVja0J1bm55XzE3NWsubW92
Enable the RTMP function of channel 1 via the API
http://192.168.0.15/control?command=live_control&channel=0&value=start&auth=f6fdffe48c908deb0f4c3bd36c032e72
Enable the RTSP function of channel 1 via the API
http://192.168.0.15/control?command=rtsp_enable_control&channel=0&value=start&auth=f6fdffe48c908deb0f4c3bd36c032e72
Set the RTMP address of channel 1 via the API
http://192.168.0.15/control?command=set_live_url&channel=0&value=cnRtcCUzQS8vbGl2ZS5oa3N0di5oay5seGRucy5jb20vbGl2ZS9oa3Mx&auth=f6fdffe48c908deb0f4c3bd36c032e72
Set the RTSP address of channel 1 via the API
http://192.168.0.15/control?command=set_live_rtsp&channel=0&value=cnRzcCUzQS8vMTg0LjcyLjIzOS4xNDkvdm9kL21wNCUzQS8vQmlnQnVja0J1bm55XzE3NWsubW92&auth=f6fdffe48c908deb0f4c3bd36c032e72&user=admin&pass=123456
Set the username and password
1. Set the username and password
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/control?command=set_user_info&user=newusername&pass=newpass&value=1&auth=userAuth
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/control?command=set_user_info&user=admin&pass=234567&value=1&auth=a66abb5684c45962d887564f08346e8d
Note: the authentication after auth is the md5-encrypted string of the username and password, for example md5(usernamepasswd)
Get the RTMP push status
1. Get the RTMP1 push status
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/jsonfile/rtmpstatus
2. Get the RTMP2 push status
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/jsonfile/rtmpstatus1
Get the RTSP pull traffic
http://serialnumber.domain:9502/jsonfile/rtspband
Pull status // 0 failed, 1 not enabled, 2 normal
http://serialnumber.domain:9502/jsonfile/rtspstatus
Get the RTMP streaming traffic
http://serialnumber.domain:9502/jsonfile/rtmpband0
Streaming status // 0 failed, 1 not enabled, 2 normal
http://serialnumber.domain:9502/jsonfile/rtmpstatus
Get the video format 0 h265, 1 unknown, 2 h264
http://serialnumber.domain:9502/jsonfile/codecstatus
Get all configuration information
Method: POST
Content: userAuth
Returns: JSON information of all device configurations
AJAX example:
var auth = userAuth
$.ajax({
type:"post",
url:"/getConfig",
data:auth,
success:function(data){
jsonobj = data;
}
})
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/getConfig
Get the LAN camera list (via the ONVIF protocol; Hikvision cameras need ONVIF enabled manually)
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/getOnvifDevices
Return value example:
{"device":[{ip:'192.168.0.136'},{ip:'192.168.0.226'},{ip:'192.168.0.67'}]}
It contains 3 cameras: 192.168.0.136, 192.168.0.226 and 192.168.0.67
Get the video playback address (RTSP address) of a camera
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/getDeviceRtsp?ip=192.168.0.67&user=admin&pass=admin
Parameter description:
ip: camera IP
user: camera username (ONVIF account)
pass: camera password (ONVIF account)
Return value description
{"rtspurl":["rtsp://192.168.0.67:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif","rtsp://192.168.0.67:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif"]}
This return value means the camera has 2 streams. Generally speaking, the first stream is the main stream with a relatively high bitrate, mainly used for local recording. The second stream is the sub stream with a relatively low bitrate, mainly used for Internet transmission.
This RTSP address can be set on the video encoder through the "Set the RTSP pull address" API.
Get the camera stream details
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/setprofile?wtype=1&ip=192.168.0.67&user=admin&pass=YWRtaW4=&index=0
Parameter description
wtype: 1 means get the stream details
ip: camera IP
user: camera username
pass: camera password, base64 encoded
index: stream index (0 = main stream, 1 = sub stream, corresponding to the "Get the camera video playback address (RTSP address)" API)
Return value example:
{"profile":[{"profile":"2"},{"BitrateLimit":"2048"},{"ConstantBitRate":"0"},{"ConstantBitRateFlag":"0"},{"FrameRateLimit":"20"},{"Height":"1080"},{"Width":"1920"}]}
Modify the camera stream details
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/setprofile?wtype=3&ip=192.168.0.67&user=admin&pass=YWRtaW4=&index=0&encodeType=2&bitrate=2048&constbitrate=0&flag=0&fps=25&height=1080&width=1920
Parameter description
wtype: 3 means set the stream details
ip: camera IP
user: camera username
pass: camera password, base64 encoded
index: stream index (0 = main stream, 1 = sub stream, corresponding to the "Get the camera video playback address (RTSP address)" API)
encodeType: 2 means h264
bitrate: sets the stream baud rate. The higher the baud rate, the more upstream bandwidth is used and the clearer the image.
constbitrate: must be 0 at present
flag: must be 0 at present
fps: video frame rate
height: video resolution height
width: video resolution width
****Note that some parameters are not supported by the camera. Therefore, after using this API to set the parameters, you must call the "Get the camera stream details" API to confirm whether the parameters were modified successfully.
PTZ control
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/ptz?command=ptz&host=cnRzcDovL2FkbWluOjEyMzRhYmNkQDE5Mi4xNjguMC42NDo1NTQvU3RyZWFtaW5nL0NoYW5uZWxzLzEwMT90cmFuc3BvcnRtb2RlPXVuaWNhc3QmcHJvZmlsZT1Qcm9maWxlXzE=&usr=admin&pass=1234abcd&value=0&auth=f6fdffe48c908deb0f4c3bd36c032e72
Parameter description:
value
u //up
d //down
l //left
r //right
1 //upper left 1
2 //upper right
3 //lower left
4 //lower right
n //zoom in
f //zoom out
i //focus in
o //focus out
t //stop focus
s //stop rotation
host the pull address of the camera to be controlled, base64 encoded
For example: host=base64(rtsp://admin:1234abcd@192.168.0.64:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1)
For UI display versions after 1.16.2, host can be filled in with the camera IP directly, in the form: host=192.168.0.15
Old-version recording
- Online playback API
http://cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502/vod/index.m3u8?command=record&start_time=151805600000&end_time=151819200000&channel=record0
Parameter description:
command has two values, record and check.
record means get the recording of the specified time period (returns an m3u8 file)
check means check whether there is a recording at the specified time (0 means none, other values mean there is)
start_time is the start time (unix timestamp, ms)
end_time is the end time (unix timestamp, ms)
channel specifies the channel - Download API
http://camera-ip-or-remote-domain/ts/?command=record&start_time=1575993600000&end_time=1576076400000&channel=record0
Parameter description
start_time is the timestamp of the start of the recording to be downloaded
end_time is the timestamp of the end of the recording to be downloaded (note that the time span must not exceed 8 hours, to avoid the file being too large)
channel. record0 means channel 1, record1 means channel 2, and so on
Keep the other fields unchanged; they cannot be modified.
New-version recording
- Recording list query (query by day only)
${videoUrl}/api/record/list?beginTime=${beginTimeMs}&endTime=${endTimeMs}&channel=${channel}
Request parameters:
videoUrl: device address 【remote: http://serialnumber.cloud.xstrive.com:9502 LAN: http://device-ip】
beginTimeMs: start timestamp, in milliseconds
endTimeMs: end timestamp, in milliseconds
channel: channel number, starting from 0
Response parameters:
mode: flv or hls, flv by default
day: 20211118, current date format string
files: [{dur: 30000, name: 123456789}]. dur: duration, name: file name, i.e. the current timestamp in milliseconds - Playback
FLV playback
Playback request:${videoUrl}/api/record/publish?beginTime=${beginTimeMs}&endTime=${endTimeMs}&channel=${channel}
Playback address:${videoUrl}/hdl/playback/record${channel}_${beginTimeMs}.flv
HLS playback
${videoUrl}/api/record/hls/vod/index.m3u8?start_time=${beginTimeMs}&end_time=${endTimeMs}&channel=${channel}
Parameter description
videoUrl: device address
beginTimeMs: start time in milliseconds
endTimeMs: end time in milliseconds
channel: current channel number, starting from 0 - Download
Single file download
${videoUrl}/playbackhls/rec/record${channel}/${playbackDay}/${name}.flv
${videoUrl}/playbackhls/rec/record${channel}/${playbackDay}/${name}.ts
Range download
${videoUrl}/api/record/hls/ts/record.ts?start_time=${beginTimeMs}&end_time=${endTimeMs}&channel=${channel}
Parameter description
videoUrl: device address
beginTimeMs: start time in milliseconds
endTimeMs: end time in milliseconds
channel: current channel number, starting from 0
playbackDay: current date format string, e.g. 20211118
name: file name, which is files[0].name returned by the recording list
Recording Player Test
http://playback.platform.xstrive.com/vod?address=http://192.168.0.140&username=admin&password=admin
Parameter description
username: device username
password: device password
address: device access address
channel: channel selected by default, starting from 0
For LAN calls
Replace cb00a8fe73ac6e8da63ea57a1c5f4785.cloud.xstrive.com:9502 in the examples with the device IP, for example 192.168.0.15
BASE64 encryption reference website
http://tool.chinaz.com/Tools/Base64.aspx