This is an old revision of the document!
To set a configuration variable, simply perform an HTTP POST to the URL
http:/server_address/cgi-bin/control.cgi
with the body
variable=value
For per-channel configuration items, the varname is written as with Cn_varname,
where n is the channel number.
The response contains a return code in JSON format.
After setting the configuration, you must start or stop the channel
for the settings to take effect.
Python example code for setting configuration:
import requests server_url='http://192.168.81.68/cgi-bin/control.cgi' r = requests.post(server_url, 'C1_enc_port=22222') print r print r.json()
To read configuration variable, simply perform an HTTP POST to the URL
http://server_address/cgi-bin/control.cgi
with the body as given below.
The reponse will be in JSON format, giving the value of each variable.
To read global configuration variables, POST with this body:
ctrl=sys&chn=null
To read encoder channel configuration variables for channel 1, POST with this body:
ctrl=enc&chn=1
To read decoder channel configuration variables for channel 1, POST with this body:
ctrl=dec&chn=1
Python example code for reading configuration:
import requests, json, sys server_url='http://192.168.81.68/cgi-bin/control.cgi' global_cfg = requests.get(server_url, params='ctrl=sys&chn=null') print global_cfg.json() enc_cfg = requests.get(server_url, params='ctrl=enc&chn=1' ) print enc_cfg.json()
sysdevicename=HE4K-01
syspassword=
enc_channels=C1
dec_channels=C1
opmode=enc_ultrahd
opstate=Idle
use_dhcp=on
Description: Global enable for this a/v encoder channel
Possible values: yes, no
Description: Video input from which encoder will source its video
Possible values: Board-dependent
Description: Video bitrate in bits per second.
Possible values: A “K” suffix indicates kilobits (thousands of bits/second).
A “M” suffix indicates megabits (millions of bits/second).
Note: In UDP transport stream case, the C1_enc_tsrate should be set
higher than the C1_enc_vbitrate, with at least 15% margin.
Description: Divide video input frame rate by this number to get encode frame rate.
The encoder will discard (frameratediv-1) out of (frameratediv) frames.
Possible values: 1, 2, 3, 4, 5, 6
Description: Distance between I frames (key frames) in GOP sequence
Possible values: 1 through 240
Description: H.264 profile (see https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Profiles for full description)
Possible values: baseline, main, high
Description: Video maximum burst size in milliseconds.
Possible values: 100 to 2000
Description: Number of B frames in GOP sequence
Possible values: 0, 1, 2
0 means GOP sequence IPPPPPP…
1 means GOP sequence IPBPBPBPBPB…
1 means GOP sequence IPBBPBBPBBPBBPBB…
Note: In 2160p mode, the interframeinterval must be set to 1
to achieve 30fps performance.
Description: Enable or disable audio encoding.
Possible values: on, off
Description: Protocol used to transport the encoded bitstream.
Possible values: rtp, rtmp, udp, asi, tsfile, mts, tsrtp
Description: Destination IP address for encoded bitstream.
Possible values: Unicast or multicast IPv4 address
Description: Destination Layer 3 port (UDP for most transports, TCP for rtmp)
Possible values: 1-65535
The following parameters only apply to transport stream encoding (transport is set to udp, asi, tsfile, mts, or tsrtp). C1_enc_vpid Description: Video PID for transport stream. Possible values: 32 to 8191 – must not conflict with other PID assignments C1_enc_apid Description: Audio PID for transport stream. Possible values: 32 to 8191 – must not conflict with other PID assignments C1_enc_pcrpid Description: PCR PID for transport stream. Possible values: 32 to 8191 – must not conflict with other PID assignments C1_enc_pmtpid Description: PMT PID for transport stream. Possible values: 16 to 31 – must not conflict with other PID assignments C1_enc_tsrate Description: Transport stream total transport rate in bits per second. Possible values: The 'K' suffix indicates kilobits (thousands of bits/second). The 'M' suffix indicates megabits (millions of bits/second). Note: In UDP transport stream case, the C1_enc_tsrate should be set higher than the C1_enc_vbitrate, with at least 15% margin. C1_enc_lowlat Description: Low latency transport stream mode (VBR). Possible values: off, on
C1_enc_audchan1_enable=yes
C1_enc_audchan1_codec=dsp_aaclc
C1_enc_audchan1_brate=128000
C1_enc_audchan1_srate=48000
C1_enc_audchan1_mode=stereo
C1_enc_audchan1_source=hdmi
C1_enc_audchan1_pid=120
C1_enc_audchan1_rtpport=8892
C1_enc_audchan1_ptspcr=250
C1_enc_audchan1_format=adts
Generic actions apply to both encoder and decoder modes.
Python example code for starting/stopping all channels:
import requests, json
import sys, getopt
actionname='StartChannel'
server_url='http://192.168.81.68'
control_cgi_url = server_url + '/cgi-bin/control.cgi'
payload = 'ctrl=sys&chn=null'
sysctrl = requests.get(control_cgi_url, params=payload)
j = sysctrl.json()
print j
dec_channels_string = j['dec_channels']
enc_channels_string = j['enc_channels']
opmode = j['opmode']
dec_channels = dec_channels_string.split( ',' )
enc_channels = enc_channels_string.split( ',' )
print 'dec_channels', dec_channels, 'enc_channels', enc_channels, 'opmode', opmode
if opmode[0:3] == 'enc':
channel_list = enc_channels
elif opmode[0:3] == 'dec':
channel_list = dec_channels
else:
print 'Bad opmode [', opmode, ']'
sys.exit(1)
for channel in channel_list :
# Remove leading C
channel = channel[1:]
print actionname, ' ', opmode, 'channel', channel
payload = 'action='+actionname+'&'+ 'chn=' +channel;
r = requests.post(control_cgi_url, payload)
print r.text
Python example of updating and reading encoder statistics:
import requests, json, sys server_url='http://192.168.81.68/cgi-bin/control.cgi' requests.post(server_url, 'action=EncoderStatus&chn=1') requests.post(server_url, 'action=StreamStatus&chn=1') requests.post(server_url, 'action=AStreamStatus&chn=1') requests.post(server_url, 'action=SourceStatus&chn=1') print requests.get(server_url, params='ctrl=stats&chn=null').json()