This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
http_api_lua [2017/02/17 16:41] johnw created |
http_api_lua [2020/02/18 16:08] johnw |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== HTTP API ====== | + | ====== HTTP API for HE4K-01 / HE4K-R4 / MVE-150 / MVE-100R / SME-01 / DME-02/03/04 / SBE264-DVR-23 / BLE264-S4 / BLE264-H4 ====== |
+ | |||
+ | |||
+ | For Camera/Sensor based products <font 12.8px/arial;;#000000;;#ffffff>(Z3Cam/FXXX)</font> and the HE1080/DME-10 use [[:http_api|Z3-Camera_Solutions-http_api]] | ||
Line 32: | Line 35: | ||
import requests | import requests | ||
- | server_url='http://192.168.81.68/cgi-bin/control.cgi' | + | server_url='http://192.168.0.120/cgi-bin/control.cgi' |
r = requests.post(server_url, 'C1_enc_port=22222') | r = requests.post(server_url, 'C1_enc_port=22222') | ||
Line 38: | Line 41: | ||
print r.json() | print r.json() | ||
</code> | </code> | ||
+ | |||
==== Reading Configuration ==== | ==== Reading Configuration ==== | ||
Line 81: | Line 85: | ||
import requests, json, sys | import requests, json, sys | ||
- | server_url='http://192.168.81.68/cgi-bin/control.cgi' | + | server_url='http://192.168.0.120/cgi-bin/control.cgi' |
global_cfg = requests.get(server_url, params='ctrl=sys&chn=null') | global_cfg = requests.get(server_url, params='ctrl=sys&chn=null') | ||
Line 89: | Line 93: | ||
print enc_cfg.json() | print enc_cfg.json() | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | ==== Persistent Configuration ==== | ||
+ | |||
+ | |||
+ | If you want the current configuration to be saved for future startups, you must explicitly perform the "SaveUser" action. | ||
+ | |||
+ | |||
+ | Python example code for saving configuration to persistent storage: | ||
+ | |||
+ | |||
+ | <code> | ||
+ | #! /usr/bin/env python | ||
+ | |||
+ | import requests, json, sys | ||
+ | from time import sleep | ||
+ | |||
+ | server_url='http://192.168.81.7/cgi-bin/control.cgi' | ||
+ | |||
+ | payload='action=SaveUser' | ||
+ | r = requests.post(server_url, payload) | ||
+ | print r | ||
+ | print r.json() | ||
+ | </code> | ||
+ | |||
===== Global Configuration ===== | ===== Global Configuration ===== | ||
Line 142: | Line 171: | ||
higher than the C1_enc_vbitrate, with at least 15% margin. | higher than the C1_enc_vbitrate, with at least 15% margin. | ||
+ | |||
==== C1_enc_frameratediv ==== | ==== C1_enc_frameratediv ==== | ||
Line 215: | Line 245: | ||
- | \\ | ||
==== C1_enc_ip ==== | ==== C1_enc_ip ==== | ||
Line 280: | Line 309: | ||
Possible values: off, on | Possible values: off, on | ||
+ | |||
+ | C1_enc_pcrinterval | ||
+ | |||
+ | Description: Interval between PCR packets in milliseconds. | ||
+ | |||
+ | Possible values: 30 - 100 | ||
+ | |||
+ | ==== C1_enc_auxonoff ==== | ||
+ | |||
+ | Describe: Enable AUXillary file recording in UDP mode – allows simultaneous UDP streaming and TS file recording on the same channel. Only valid if transport is UDP and tslowlat is off | ||
+ | |||
+ | The path to storage is set by the “storage” parameter. | ||
+ | |||
+ | The filename is set by the “fprefix” parameter. The default value is “MOV1_%F_%T”. The ”%F” specifier inserts a date stamp, and the ”%T” specifier inserts a time stamp. | ||
+ | |||
+ | The recording file size is set by the “filesize” parameter. When the file reaches this size, a new file will be created. | ||
+ | |||
+ | ==== C1_enc_fprefix ==== | ||
+ | |||
+ | Description: Relative filename for TSFILE or AUX file recording. Note that “fprefix” does NOT include the absolute media path – the “storage” parameter is the proper place to specify the absolute media path. | ||
+ | |||
+ | ==== C1_enc_storage ==== | ||
+ | |||
+ | Absolute path to mounted media device (e.g. /media/sda1/) | ||
</file> | </file> | ||
+ | |||
+ | |||
+ | ===== Encoder Audio Configuration ===== | ||
Line 337: | Line 393: | ||
- | \\ | + | %%\%% |
+ | |||
==== C1_enc_audchan1_pid ==== | ==== C1_enc_audchan1_pid ==== | ||
Line 347: | Line 405: | ||
- | \\ | + | %%\%% |
+ | |||
==== C1_enc_audchan1_rtpport ==== | ==== C1_enc_audchan1_rtpport ==== | ||
Line 354: | Line 414: | ||
- | \\ | + | %%\%% |
+ | |||
==== C1_enc_audchan1_ptspcr ==== | ==== C1_enc_audchan1_ptspcr ==== | ||
- | Description: For transport stream modes only -- intial PTS to PCR offset for audio, in milliseconds | + | Description: For transport stream modes only – intial PTS to PCR offset for audio, in milliseconds |
Line 364: | Line 426: | ||
- | \\ | + | %%\%% |
+ | |||
==== C1_enc_audchan1_format ==== | ==== C1_enc_audchan1_format ==== | ||
Line 372: | Line 436: | ||
Possible values: adts | Possible values: adts | ||
+ | |||
+ | |||
+ | ===== Encoder Text Overlay Configuration (only for DME-02/03/04, SBE264-01, SBE264-DVR-23, BLE264-S4, BLE264-H4) ===== | ||
+ | |||
+ | |||
+ | ==== C1_enc_ovlglobalalpha ==== | ||
+ | |||
+ | |||
+ | Description: Global alpha blending setting | ||
+ | |||
+ | |||
+ | Possible values: 0 (totally transparent) to 100 (totally opaque) | ||
+ | |||
+ | |||
+ | ==== C1_enc_ovltext ==== | ||
+ | |||
+ | |||
+ | Description: ASCII Text to draw | ||
+ | |||
+ | |||
+ | ==== C1_enc_ovltextenable ==== | ||
+ | |||
+ | |||
+ | Description: Enable or disable text overlay | ||
+ | |||
+ | |||
+ | Possible values: on, off | ||
+ | |||
+ | |||
+ | ==== C1_enc_ovltextlocation ==== | ||
+ | |||
+ | |||
+ | Description: Set position of overlay text onscreen | ||
+ | |||
+ | |||
+ | Possible values: top_left, top_right, top_center, bottom_left, bottom_right, bottom_center | ||
Line 386: | Line 486: | ||
actionname='StartChannel' | actionname='StartChannel' | ||
- | server_url='http://192.168.81.68' | + | server_url='http://192.168.0.120' |
control_cgi_url = server_url + '/cgi-bin/control.cgi' | control_cgi_url = server_url + '/cgi-bin/control.cgi' | ||
Line 417: | Line 517: | ||
channel = channel[1:] | channel = channel[1:] | ||
print actionname, ' ', opmode, 'channel', channel | print actionname, ' ', opmode, 'channel', channel | ||
- | payload = 'action='+actionname+'&'+ 'chn=' +channel; | + | payload = 'action='+actionname+'&'+ 'chn=' +channel+'&' + 'loadfromdb=true'; |
+ | headers={'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'} | ||
r = requests.post(control_cgi_url, payload) | r = requests.post(control_cgi_url, payload) | ||
print r.text | print r.text | ||
</code> | </code> | ||
+ | |||
==== StartChannel ==== | ==== StartChannel ==== | ||
Line 431: | Line 534: | ||
Once you start the channel, it will not transmit data until the\\ | Once you start the channel, it will not transmit data until the\\ | ||
video input is detected. | video input is detected. | ||
+ | |||
==== StopChannel ==== | ==== StopChannel ==== | ||
Line 437: | Line 541: | ||
Transition the encoder or decoder channel into the stopped state. | Transition the encoder or decoder channel into the stopped state. | ||
+ | |||
+ | ==== GetStorage ==== | ||
+ | |||
+ | |||
+ | Reads the device files and mount points of available storage. The following example shows an SD card device /dev/mmcblk0p1 mounted at the directory /media/mmcblk0p1 and a USB device /dev/sda1 mounted at the directory /media/sda1 | ||
+ | |||
+ | |||
+ | <code> | ||
+ | import requests, json, sys | ||
+ | |||
+ | payload='action=GetStorage' | ||
+ | r = requests.post(server_url, payload) | ||
+ | print r | ||
+ | print r.json() | ||
+ | </code> | ||
+ | |||
+ | |||
+ | Output: <Response [200]> {u'mounts': u'/dev/mmcblk0p1 /media/mmcblk0p1/,/dev/sda1 /media/sda1/,', u'ret': u'0'} | ||
+ | |||
+ | |||
+ | ==== Dynamic ==== | ||
+ | |||
+ | |||
+ | Set a dynamic parameter after encoding has already started | ||
+ | |||
+ | |||
+ | <code> | ||
+ | chn='1' | ||
+ | variable='auxfile' | ||
+ | value='off' | ||
+ | payload='action=Dynamic&chn=' + chn + '&var=' + variable + '&val=' + value | ||
+ | |||
+ | r = requests.post(server_url, payload) | ||
+ | print r | ||
+ | print r.json() | ||
+ | </code> | ||
+ | |||
+ | |||
+ | <code> | ||
+ | vratediv Set video frame rate divider | ||
+ | vrate Set bitrate | ||
+ | auxfile Dynamically start/stop auxfile recording (value is either on or off) | ||
+ | </code> | ||
+ | |||
+ | |||
+ | The auxfile command will return a status from the table below. | ||
+ | |||
+ | |||
+ | ^Auxfile status ^Number | | ||
+ | | VCAP_VENC_ERR_NO_SPACE |-26 | | ||
+ | | VCAP_VENC_ERR_THREAD_ERR |-25 | | ||
+ | | VCAP_VENC_ERR_BAD_MOUNTPOINT |-24 | | ||
+ | | VCAP_VENC_ERR_STOPPING_AUDIO |-23 | | ||
+ | | VCAP_VENC_ERR_MTS_INVALID_DEST |-22 | | ||
+ | | VCAP_VENC_ERR_MTS_BAD_UDP_DEST |-21 | | ||
+ | | VCAP_VENC_ERR_INSUFFICIENT_TS_RATE |-20 | | ||
+ | | VCAP_VENC_ERR_NO_SPARE_MTS_BW |-19 | | ||
+ | | VCAP_VENC_ERR_MTS_START_FAILURE |-18 | | ||
+ | | VCAP_VENC_ERR_MTS_DUPLICATE_DEST |-17 | | ||
+ | | VCAP_VENC_ERR_MTS_DUPLICATE_NAME |-16 | | ||
+ | | VCAP_VENC_ERR_MTS_TEARDOWN_FAILURE |-15 | | ||
+ | | VCAP_VENC_ERR_MTS_NAME_NOT_FOUND |-14 | | ||
+ | | VCAP_VENC_ERR_MTS_CREATE_FAILURE |-13 | | ||
+ | | VCAP_VENC_ERR_MTS_RATE_MISMATCH |-12 | | ||
+ | | VCAP_VENC_ERR_MTS_NO_FREE_INFO |-11 | | ||
+ | | VCAP_VENC_ERR_NOT_IMPLEMENTED |-10 | | ||
+ | | VCAP_VENC_ERR_AUDIO_CAPTURE_SINK |-8 | | ||
+ | | VCAP_VENC_ERR_NO_FREE_AUDIO_STREAM |-7 | | ||
+ | | VCAP_VENC_ERR_VIDEO_FILE_NAME_PARSE |-6 | | ||
+ | | VCAP_VENC_ERR_STREAM_NOT_RUNNING |-5 | | ||
+ | | VCAP_VENC_ERR_STREAM_HAS_CHILDREN |-4 | | ||
+ | | VCAP_VENC_ERR_AUDIO_CAPTURE_SOURCE |-3 | | ||
+ | | VCAP_VENC_ERR_STARTING_AUDIO |-2 | | ||
+ | | VCAP_VENC_ERR_BAD_DESTINATION |-1 | | ||
+ | | VCAP_VENC_SUCCESS |0 | | ||
+ | | VCAP_VENC_WARN_ALREADY_STARTED |1 | | ||
Line 447: | Line 627: | ||
To read the result, you need to POST the "stats" control as shown\\ | To read the result, you need to POST the "stats" control as shown\\ | ||
in the Python example code below. | in the Python example code below. | ||
+ | |||
==== StreamStatus ==== | ==== StreamStatus ==== | ||
Line 456: | Line 637: | ||
To read the result, you need to POST the "stats" control as shown\\ | To read the result, you need to POST the "stats" control as shown\\ | ||
in the Python example code below. | in the Python example code below. | ||
+ | |||
==== AStreamStatus ==== | ==== AStreamStatus ==== | ||
Line 465: | Line 647: | ||
To read the result, you need to POST the “stats” control as shown\\ | To read the result, you need to POST the “stats” control as shown\\ | ||
in the Python example code below. | in the Python example code below. | ||
+ | |||
==== SourceStatus ==== | ==== SourceStatus ==== | ||
Line 474: | Line 657: | ||
To read the result, you need to POST the “stats” control as shown\\ | To read the result, you need to POST the “stats” control as shown\\ | ||
in the Python example code below. | in the Python example code below. | ||
+ | |||
===== Reading Statistics ===== | ===== Reading Statistics ===== | ||
Line 483: | Line 667: | ||
<code> | <code> | ||
import requests, json, sys | import requests, json, sys | ||
- | server_url='http://192.168.81.68/cgi-bin/control.cgi' | + | server_url='http://192.168.0.120/cgi-bin/control.cgi' |
requests.post(server_url, 'action=EncoderStatus&chn=1') | requests.post(server_url, 'action=EncoderStatus&chn=1') | ||
Line 498: | Line 682: | ||
<code> | <code> | ||
- | |||
{u'astream_status_str': u'Channel 1 Subchannel 1 Codec dsp_aaclc +OK', | {u'astream_status_str': u'Channel 1 Subchannel 1 Codec dsp_aaclc +OK', | ||
u'ret': u'0', | u'ret': u'0', | ||
Line 510: | Line 693: | ||
u'stream_status_str': u'Channel 1 URL rtp://192.168.0.6:5004 Frames 140 +OK'} | u'stream_status_str': u'Channel 1 URL rtp://192.168.0.6:5004 Frames 140 +OK'} | ||
</code> | </code> | ||
+ | |||
+ | |||
+ | \\ | ||
+ |