Mirror of this article: https://linkpi.cn/archives/1388
Link to this article: https://blog.csdn.net/weixin_45326556/article/details/123679784
Lingpai encoder HTTP API interface description
- 1. Summary and Disclaimer
- 2. Design Description
- 3. LPH protocol API description
-
- 3.1 Login request /link/user/lph_login
- 3.2 Logout request /link/user/lph_logout
- 3.3 Get system status information/link/system/get_sys_state
- 3.4 Get the system network status/link/system/get_net_state
- 3.5 Get HDMI/SDI channel interface status/link/system/get_vi_state
- 3.6 Get network configuration information/link/system/get_network
- 3.7 Set network configuration /link/system/set_network
- 3.8 Get system time/link/system/get_sys_date
- 3.9 Set system time/link/system/set_sys_date
- 3.10 Get ntp service information/link/system/get_ntpd
- 3.11 Set ntp service /link/system/set_ntpd
- 3.12 Get video channel encoding information/link/encoder/get_enc_confs
- 3.13 Update network input source parameters /link/encoder/set_net_chns
- 3.14 Set input source encoding parameters/link/encoder/set_enc_chns
- 3.15 Set HDMI/SDI crop rotation video parameters/link/encoder/set_cap_chns
- 2.16 Set audio encoding parameters/link/encoder/set_audio_chns
- 3.17 Get video stream output configuration/link/stream/get_stream_confs
- 3.18 Set video stream output configuration/link/stream/set_stream_confs
- 3.19 Get hls ndi ts configuration information/link/stream/get_hls_ndi_ts
- 3.20 Set hls ndi ts configuration information/link/stream/set_hls_ndi_ts
- 3.21 Get multi-platform live broadcast configuration information/link/stream/get_platform_lives
- 3.22 Set multi-platform live broadcast configuration information/link/stream/set_platform_lives
- 3.23 Multi-platform live broadcast start/link/stream/start_platform_lives
- 3.24 Multi-platform live broadcast stop /link/stream/stop_platform_lives
- 3.25 Get multi-platform live broadcast status/link/stream/get_platform_lives_state
- 3.26 Get watermark configuration parameters/link/overlay/get_overlay_confs
- 3.27 Set watermark configuration parameters/link/overlay/set_overlay_confs
- 3.28 Get all preset layout information/link/layout/get_deflay_confs
- 3.29 Get the video layout and audio mixing information used/link/layout/get_layout_confs
- 3.30 Video layout switching, audio mixing/link/layout/set_layout_confs
- 3.31 Get HDMI, VGA output configuration information/link/output/get_output_confs
- 3.32 Set HDMI, VGA output configuration information/link/output/set_output_confs
- 3.33 Get recording parameters/link/record/get_record_confs
- 3.34 Set global recording parameters/link/record/set_record_confs
- 3.35 Start recording /link/record/start_rec
- 3.36 Stop recording all/link/record/stop_rec
1. Summary and Disclaimer
The background of Lingpai Encoder is implemented in PHP. If there is a need for customization, you can modify its source code by yourself. For the background source code of Lingpai Encoder, please refer to https://gitee.com/LinkPi/Encoder/tree/web . Some users need to control the encoder in their own server or self-written software, which can be done by calling the Lingpai encoder HTTP API interface. For the convenience of discussion, we define the Lingpai encoder HTTP API interface as the LPH interface .
Due to product version upgrades or other reasons, the content of this document will continue to be updated. Unless otherwise agreed, this document is only used as a guide, and all statements, information and suggestions in this document do not constitute any express or implied guarantee.
2. Design Description
2.1 Introduction to LPH protocol
The LPH protocol is an API interface defined on top of HTTP, and its essence still belongs to the HTTP protocol. On the basis of HTTP, the LPH protocol adds the interactive process of Digest authentication and login authentication.
2.2 Description of LPH protocol interaction process
2.2.1 Communication interaction process
The main differences between the HTTP interaction process with Digest authentication and the standard HTTP interaction process of the LPH command are as follows:
The LPH protocol currently only supports the Digest authentication process, and the default authentication user name and password are both admin.
Next, we use postman as a client to illustrate a communication process. Here we take login (/link/user/lph_login) as an example.
(1) First, we start postman, and open the postman console tool as shown below, and clear the console information
(2) Create a request, the url is /link/usr/lph_login, the request method is GET/POST, and the delivery is set Parameters, here take the GET request as an example, as shown in the figure below
(3) Set the postman Http authentication method, and set the user name and password, as shown in the figure below
(4) Click the Send button to send the request, and then open the postman console tool, you can see 2 Request records, as shown in the following figure
(5) By comparison, we can see that the first time the client sends a request to the server, the server returns 401, and carries the WWW-Authenticate authentication
information in the response header, and the postman client gets the authentication information After that, the Authenticate is calculated and added to the request header, and sent again.
(6) After the server authentication is passed, the request result will be returned, as shown in the figure below
2.2.2 LPH protocol API call process
Through the example in 2.2.1, we know that the Authorization header information is required during the communication process, but the request headers other than the login request must carry not only the Authorization information but also the 3 sets of HASH values obtained by the login to make the request successful.
Here is a brief description of the interaction process by obtaining video channel information:
(1) To send a request, you must first log in to the server /link/user/lph_login
(2) After logging in, you will send /link/encoder/get_channels to obtain video channel information
(3) After obtaining information logout /link/user/lph_logout
As shown in the figure below, after the login is successful, add 3 HASH values to the request header of the API for obtaining video channel information, and then you can get the correct request result.
3. LPH protocol API description
3.1 Login request /link/user/lph_login
Request type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
username | string | yes | Login user name, same as login web user name |
passwd | string | yes | The login password, which is the same as the login password for the web, needs to be encrypted by md5 before transmission |
response
{
"data": {
"L-HASH": "0b3bb1f7fcdffc5ea1077090b9bbc43314fa4268",
"P-HASH": "29a07d69a3e5f9b8ef42eee9d5a837af2ff0f403",
"H-HASH": "9d181efb0c1b606f5a7fef2a45b1385a447794f3"
},
"status": "success",
"msg": "登录成功"
}
3.2 Logout request /link/user/lph_logout
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": "",
"status": "success",
"msg": "登出成功"
}
3.3 Get system status information/link/system/get_sys_state
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": {
"cpu": 17, //cpu百分比使用率
"mem": 41, //内存百分比使用率
"temperature": 42 //核心温度,摄氏度
},
"status": "success",
"msg": "执行完成"
}
3.4 Get the system network status/link/system/get_net_state
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": {
"rx": 0, //网络下行
"tx": 0 //网络上行
},
"status": "success",
"msg": "执行完成"
}
3.5 Get HDMI/SDI channel interface status/link/system/get_vi_state
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": [
{
"avalible": true, //是否有hdm/sdi输入源接入
"framerate": 50, //帧率
"full": false,
"height": 1080, //视频高
"interlace": false, //是否隔行扫描
"protocol": "HDMI", //输入源类型
"samplerate": 48000, //音频采样率
"width": 1920 //视频宽
},
…………
],
"status": "success",
"msg": "执行完成"
}
3.6 Get network configuration information/link/system/get_network
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": {
"ip": "192.168.1.213",
"mask": "255.255.252.0", //掩码
"gateway": "192.168.1.1", //网关
"dns": "8.8.8.8",
"mac": "886570e99627"
"dhcp": false
},
"status": "success",
"msg": "执行完成"
}
3.7 Set network configuration /link/system/set_network
Request type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
ip | string | no | ip address |
mask | string | no | subnet mask |
gateway | string | no | gateway |
dns | string | no | dns |
dhcp | bool | no | Whether to automatically obtain ip, when the value is true, other parameters will be ignored |
Response
No return value
3.8 Get system time/link/system/get_sys_date
Request type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
none | none | none | none |
response
{
"data": "2021-11-11 03:37:28",
"status": "success",
"msg": "执行完成"
}
3.9 Set system time/link/system/set_sys_date
Request type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
sysDate | string | yes | The parameter format is and only: "yyyy/MM/dd/hh/mm/ss" |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.10 Get ntp service information/link/system/get_ntpd
Request type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
none | none | none | none |
response
{
"data": {
"server": "cn.pool.ntp.org", //ntp服务器地址
"enable": false //开机是否同步ntp服务器时间
},
"status": "success",
"msg": "执行完成"
}
3.11 Set ntp service /link/system/set_ntpd
Request type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
server | string | no | NTP server address, such as cn.pool.ntp.org |
enable | bool | no | Whether to synchronize ntp time when booting |
sync | bool | no | Whether to synchronize the ntp time immediately |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.12 Get video channel encoding information/link/encoder/get_enc_confs
Request type: GET/POST
parameters
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
none | none | none | none |
response
{
"data": [
{
"id": 0, //通道id
"name": "HDMI", //通道名称
"type": "vi", //通道类型,共有vi usb net mix4种
"enable": true, //通道总开关,主码流编码开关
"enable2": false, //子码流编码开关
"encv": {
//主码流编码参数
"Iqp": 25, //I帧量化因子
"Pqp": 25, //P帧量化因子
"bitrate": 4000, //码率 kb/s
"codec": "h264", //编码格式
"framerate": 30, //帧率
"gop": 2, //gop长度
"gopmode": 0, //海思gop模式,0--Normal 1--SmarP 2--DualP 3--Bipred
"height": 1080, //视频高
"lowLatency": false, //是否低延时编码
"maxqp": 36, //最大量化因子
"minqp": 22, //最小量化因子
"profile": "main", //编码压缩方式
"rcmode": "cbr", //码率控制
"width": 1920 //视频宽
},
"encv2": {
//子码流参数,同encv
"Iqp": 25,
"Pqp": 25,
"bitrate": 1000,
"codec": "h264",
"framerate": 30,
"gop": 1,
"gopmode": 0,
"height": 360,
"lowLatency": false,
"maxqp": 36,
"minqp": 22,
"profile": "high",
"rcmode": "avbr",
"width": 640
},
"enca": {
//音频编码参数
"audioSrc": "hdmi", //使用的音频源
"bitrate": 128, // 码率 kb/s
"channels": 1, //声道 1代表单声道,2代表立体声
"codec": "aac", //音频编码格式
"gain": 6, //声音增益
"samplerate": 48000 //采样率
},
"cap": {
//视频参数,该属性为vi通道(HDMI/SDI)特有属性,其他通道不存在
"crop": {
"B": 0, //视频下采集,单位像素
"L": 0, //视频左采集,单位像素
"R": 0, //视频右采集,单位像素
"T": 0 //视频上采集,单位像素
},
"deinterlace": false, //是否全帧去隔行
"rotate": 0 //旋转角度
},
"net": {
//网络输入,该属性为net通道特有属性,其他通道不存在
"bufferMode": 0, //缓冲模式
"decodeA": false, //是否音频解码
"decodeV": false, //是否视频解码
"framerate": -1, //帧率
"minDelay": 500, //缓冲时间,单位毫秒
"path": "rtsp://192.168.2.182/1", //网络流地址
"protocol": "tcp" //传输协议
}
},
…………
],
"status": "success",
"msg": "执行完成"
}
3.13 Update network input source parameters /link/encoder/set_net_chns
Request type: POST
parameter
Parameter Type | describe |
---|---|
string | The parameter is a JsonArray string, examples are shown in the following table |
parameter example
[
{
"id":2,
"path":"rtsp://192.168.2.180/1",
"decodeV":true,
"enable":true
},
…………
NetObject,
NetObject
]
See the following table for NetObject object properties
attribute name | Field Type | Is it mandatory | describe |
---|---|---|---|
id | int | yes | channel id |
name | string | no | channel name |
path | string | no | network stream address |
bufferMode | int | no | Buffer mode 0: normal 1: real time 2: synchronous |
minDelay | int | no | Buffer time, in milliseconds |
protocol | string | no | Transport protocol, tcp\upd |
framerate | int | no | frame rate |
decodeV | bool | no | Whether video decoding |
decodeA | bool | no | Whether audio decoding |
enable | bool | no | The main switch of the channel, whether to open the stream |
enable2 | bool | no | Whether to enable sub-stream, valid when video decoding is enabled |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.14 Set input source encoding parameters/link/encoder/set_enc_chns
Request type: POST
parameter
Parameter Type | describe |
---|---|
string | The parameter is a JsonArray string, examples are shown in the following table |
parameter example
[
{
"id":2,
"name":"HDMI",
"enable":true,
"enable2":false,
"encv":{
"width":1920,
"height":1080,
"codec":"h264",
"profile":"main",
"rcmode":"cbr"
},
"encv2":{
"width":640,
"height":360
}
},
…………
ChnObject
]
ChnObject object properties see the table below
parameter name | Field Type | Is it mandatory | describe |
---|---|---|---|
id | int | yes | channel id |
name | string | no | channel name |
enable | bool | no | Channel main switch, main stream encoding switch |
enable2 | bool | no | Sub stream encoding switch |
encv | EncObject | no | The encoding parameters of the main stream, object type, and attributes are shown in the table below |
env2 | EncObject | no | Substream encoding parameters, object type, and attributes are shown in the table below |
EncObject
attribute name | Field Type | Is it mandatory | describe |
---|---|---|---|
width | int | no | Video width, when the value is -1, the default width of the input source is used |
height | int | no | Video height, when the value is -1, that is, the default height of the input source is used |
codec | string | no | Encoding method, optional value: h264 h265 close |
profile | string | no | Encoding compression method, optional value: base main high |
rcmode | string | no | Rate control, optional value cbr vbr avbr fixqp |
bitrate | string | no | Code rate kb/s |
framerate | string | no | frame rate |
gop | int | no | gop length |
gopmode | int | no | Hisilicon GOP mode, 0–Normal 1–SmarP 2–DualP 3–BipredB |
minqp | Int | no | 最小量化因子 |
maxqp | int | 否 | 最大量化因子 |
Iqp | int | 否 | I帧量化因子 |
Pqp | int | 否 | P帧量化因子 |
lowLatency | bool | 否 | 是否低延时编码 |
响应
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.15 设置HDMI/SDI裁剪旋转视频参数 /link/encoder/set_cap_chns
请求类型: POST
参数
参数类型 | 描述 |
---|---|
string | 参数为JsonArray字符串,示例如下表 |
参数示例
[
{
"id":2,
"L":"200",
"rotate":90,
},
…………
CapObject
]
CapObject对象属性见下表
属性名 | 字段类型 | 描述 |
---|---|---|
id | int | 通道id |
deinterlace | bool | 是否全帧去隔行 |
rotate | int | 视频旋转,可选值0 90 180 270 |
L | int | 视频裁决左,单位像素 |
R | int | 视频裁决右,单位像素 |
T | int | 视频裁决上,单位像素 |
B | int | 视频裁决下,单位像素 |
响应
{
"data": "",
"status": "success",
"msg": "执行完成"
}
2.16 设置音频编码参数 /link/encoder/set_audio_chns
请求类型:POST
参数
参数类型 | 描述 |
---|---|
string | 参数为JsonArray字符串,示例如下表 |
参数示例
[
{
"id":2,
"codec":"aac",
" audioSrc":"hdmi",
" gain":"6"
},
…………
AudioObject
]
AudioObject对象属性见下表
属性名 | 字段类型 | 描述 |
---|---|---|
id | int | 通道id |
codec | string | 编码格式,可选值 aac pcma mp2 mp3 opus close |
audioSrc | string | 音频来源,可选值hdmi sdi line |
gain | int | 声音增益,可选值-24 -18 -12 -6 0 6 12 18 24 |
samplerate | int | 采样率,可选值 16000 32000 44100 48000 -1(-1代表自动) |
channels | int | 声道,可选值1—单声道 2—立体声 |
bitrate | int | 码率 kb/s |
响应
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.17 获取视频流输出配置 /link/stream/get_stream_confs
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": [
{
"id": 0, //通道id
"name": "HDMI", //通道名称
"type": "vi", //通道类型
"enable": true, //通道总开关,主码流开关
"enable2": false, //子码流开关
"stream": {
//主码流输出
"hls": false, //输出hls流开关
"http": true, //输出tsHttp流开关
"push": {
//推流参数
"enable": false, //是否开启推流
"format": "auto", //封装格式
"hevc_id": 12, //rtmp输出时,h265数据使用的id号
"path": "rtmp://127.0.0.1/live/test_main0" //推流地址
},
"rtmp": true, //输出rtmp流开关
"rtsp": true, //输出rtsp流开关
"srt": {
//srt流参数
"enable": false, //是否开启rtsp流
"ip": "127.0.0.1", //ip地址
"latency": 50, //延时
"mode": "listener", //模式
"passwd": "", //密码
"port": 9001, //端口
"streamid": "" // stream id
},
"udp": {
//组播参数
"bandwidth": 100, //流控最大带宽
"enable": false, //是否开启组播
"flowCtrl": true, //是否开启流控
"ip": "233.233.2.1", //地址
"port": 3000, //端口
"rtp": false, //是否增加rtp头
"ttl": 5 //ttl
}
},
"stream2": {
//子码流输出,参数主码流输出
"hls": false,
"http": true,
"push": {
"enable": false,
"format": "auto",
"hevc_id": 12,
"path": "rtmp://127.0.0.1/live/test_sub0"
},
"rtmp": true,
"rtsp": true,
"srt": {
"enable": false,
"ip": "127.0.0.1",
"latency": 50,
"mode": "listener",
"passwd": "",
"port": 9101,
"streamid": ""
},
"udp": {
"bandwidth": 100,
"enable": false,
"flowCtrl": true,
"ip": "233.233.3.1",
"port": 3000,
"rtp": false,
"ttl": 5
}
}
},
…………
],
"status": "success",
"msg": "执行完成"
}
3.18 设置视频流输出配置 /link/stream/set_stream_confs
请求类型: POST
参数
参数类型 | 描述 |
---|---|
string | 参数为JsonArray字符串,示例如下表 |
参数示例
[
{
"id":0,
"stream":{
"hls":true,
"http": false,
"rtsp":true,
"udp":{
"enable":true
}
},
"stream2":{
"rtmp":true,
"http":false,
"hls":false,
"push":{
"enable":true,
"path":"rtmp://192.168.2.110/live/main"
},
"udp":{
"enable":false
}
}
},
ChnObject,
ChnObject,
ChnObject,
…………
]
ChnObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
id | int | 是 | 通道id |
stream | StreamObject | 否 | 主码流输出参数 |
Stream2 | StreamObject | 否 | 子码流输出参数 |
StreamObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
hls | bool | 否 | 是否输出hls流 |
http | bool | 否 | 是否输出http流 |
rtmp | bool | 否 | 是否输出rtmp流 |
rtsp | bool | 否 | 是否输出rtsp流 |
push | PushObject | 否 | 推流配置参数 |
udp | UdpObject | 否 | udp组播配置参数 |
srt | SrtObject | 否 | srt流配置参数 |
PushObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
enable | bool | 否 | 是否开启推流 |
format | string | 否 | 封装格式,值可为auto flv rtsp rtp mpegts rtp_mpegts |
hevc_id | int | 否 | rtmp输出时,h265数据使用的id号 |
path | string | 否 | 推流地址 |
UdpObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
bandwidth | int | 否 | 流控最大带宽,单位Mb |
enable | bool | 否 | 是否开启组播 |
flowCtrl | bool | 否 | 流控,让码流发送更均匀,防止丢包,但是消耗一些性能 |
ip | string | 否 | 地址 |
port | int | 否 | 端口 |
rtp | bool | 否 | 是否增加rtp头 |
ttl | int | 否 | ttl |
SrtObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
latency | int | 否 | 延时 |
enable | bool | 否 | 是否开启srt流 |
mode | string | 否 | 模式,caller listener rendezvous |
ip | string | 否 | 地址 |
port | int | 否 | 端口 |
passwd | string | 否 | 密码 |
streamid | int | 否 | 流id |
响应
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.19 获取hls ndi ts 配置信息 /link/stream/get_hls_ndi_ts
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": [
{
"id": 0, //通道id
"name": "HDMI", //通道名称
"type": "vi", //通道类型
"enable": true, //通道总开关,主码流编码是否启用
"enable2": true, //子码流编码否启用
"hls": {
"hls_base_url": "/hls/", //url前缀
"hls_filename": "-%06d.ts", //文件名后缀
"hls_list_size": 5, //列表长度
"hls_time": 5 //分片长度
},
"ndi": {
"enable": false, //开关
"group": "", //NDI 分组
"name": "stream0" //NDI 名称
},
"ts": {
"mpegts_original_network_id": 1, //network id
"mpegts_pmt_start_pid": 4096, //pmt pid
"mpegts_service_id": 1, // service id
"mpegts_start_pid": 100, // pid
"mpegts_transport_stream_id": 1, //stream id
"tsSize": 1316 //packet size
}
}
],
"status": "success",
"msg": "执行完成"
}
3.20 设置hls ndi ts 配置信息 /link/stream/set_hls_ndi_ts
请求类型: POST
参数
参数类型 | 描述 |
---|---|
string | 参数为JsonArray字符串,示例如下表 |
参数示例
[
{
"id":0,
"hls":{
"hls_time":5,
"hls_list_size":5
},
"ndi": {
"enable":true,
"name":"stream0"
},
"ts": {
"mpegts_pmt_start_pid":4096,
"mpegts_original_network_id":1,
"mpegts_start_pid":100
}
}
,
ChnObject,
ChnObject,
ChnObject,
…………
]
ChnObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
id | int | 是 | 通道id |
hls | HlsObject | 否 | hls输出参数 |
ndi | NdiObject | 否 | ndi输出参数 |
ts | TsObject | 否 | ts输出参数 |
HlsObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
hls_base_url | string | 否 | url前缀 |
hls_filename | string | 否 | 文件名后缀:如-%06d.ts |
hls_list_size | int | 否 | m3u8文件分片列表长度 |
hls_time | int | 否 | 分片长度,单位秒 |
NdiObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
enable | bool | 否 | 开启/关闭 |
group | string | 否 | NDI分组 |
name | string | 否 | NDI名称 |
TsObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
mpegts_original_network_id | int | 否 | network id |
mpegts_pmt_start_pid | int | 否 | pmt pid |
mpegts_service_id | int | 否 | service id |
mpegts_start_pid | int | 否 | pid |
mpegts_transport_stream_id | int | 否 | stream id |
tsSize | int | 否 | packet size |
响应
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.21 获取多平台直播配置信息 /link/stream/get_platform_lives
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": {
"autorun": false, //是否自动启动
"srcA": 0, //音频源
"srcV": 0, //视频源
"url": [
{
"des": "直播平台1", //描述
"enable": true, //是否开启
"path": "rtmp://127.0.0.1/live/push1" //推流地址
},
{
"des": "直播平台2",
"enable": true,
"path": "rtmp://127.0.0.1/live/push2" },
{
"des": "直播平台3",
"enable": false,
"path": "rtmp://127.0.0.1/live/push3" }
]
},
"status": "success",
"msg": "执行完成"
}
3.22 设置多平台直播配置信息 /link/stream/set_platform_lives
请求类型: POST
参数
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
autorun | bool | 否 | 是否自动开启 |
srcA | int | 否 | 音频源 |
srcV | int | 否 | 视频源 |
url | array | 否 | 地址集合,里面存放UrlObject对象 |
UrlObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
des | string | 是 | 平台描述 |
enable | bool | 是 | 使用启用 |
path | string | 是 | 地址 |
参数示例
{
"autorun": false,
"srcA": 0,
"srcV": 0,
"url": [
{
"des": "直播平台1",
"enable": true,
"path": "rtmp://127.0.0.1/live/push1"
},
{
"des": "直播平台2",
"enable": true,
"path": "rtmp://127.0.0.1/live/push2"
},
{
"des": "直播平台3",
"enable": false,
"path": "rtmp://127.0.0.1/live/push3"
},
{
"des": "直播平台4",
"enable": false,
"path": "rtmp://127.0.0.1/live/push4"
}
]
}
响应
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.23 多平台直播启动 /link/stream/start_platform_lives
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": "",
"status": "success",
"msg": "执行完成" //注意:如果没有挂载外部存储设备,会启动录制失败
}
3.24 多平台直播停止 /link/stream/stop_platform_lives
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.25 获取多平台直播状态 /link/stream/get_platform_lives_state
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": {
"duration": 243945, //启动持续时间,单位ms
"pushing": true, //多平台直播状态
"speed": [ //每个平台地址的速度,和保存的直播平台是一一对应关系
2406, //速度 kb/s
2406,
0,
0
]
},
"status": "success",
"msg": "执行完成"
}
3.26 获取水印配置参数 /link/overlay/get_overlay_confs
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": [
{
"id": 0, //通道id
"name": "HDMI", //通道名称
"type": "vi", //通道类型
"enable": true, //通道总开关,主码流是否启用
"enable2": false, //子码流是否启用
"overlay": [ //水印参数,下面展示全部6种水印类型,实际中根据设置的类型和参数返回
{
"type": "text", //叠加类型为文本
"enable": true, //显示该叠加层
"font": "/link/res/font.ttf", //字体文件路径
"content": "我是水印", //文字内容,最多支持250个字
"x": 0.1, //叠加层坐标[0,1],相对于整个图像
"y": 0.136, //同上
"scale": 2.2, //文字相对大小,不同的字体表现不同,[0.1,4]
"color": "#669900", //文字颜色,RGB
"bgColor": "", //文字颜色,RGBA,留空表示透明
"alpha": 1, //叠加层透明度
"move": -1, //负数向左滚动,正数向右滚动,数值越大速度越快
"w":0.515 //叠加层宽度,主要用于限制滚动范围。
},
{
"type": "time", //叠加类型为时间戳
"enable": true, //显示该叠加层
"font": "/link/res/font.ttf", //字体文件路径
"content": "yyyy年MM月dd日 hh:mm:ss", //时间格式
"x": 0.1, //叠加层坐标[0,1],相对于整个图像
"y": 0.136, //同上
"scale": 2.2, //文字相对大小,不同的字体表现不同,[0.1,4]
"color": "#669900", //文字颜色,RGB
"bgColor": "", //文字颜色,RGBA,留空表示透明
"alpha": 1 //叠加层透明度
},
{
"type": "pic", //叠加类型为图像
"enable": true, //显示该叠加层
"content": "/link/res/logo.png", //图片路径
"x": 0.1, //叠加层坐标[0,1],相对于整个图像
"y": 0.1, //同上
"scale": 1, //图片等比缩放倍数,[0.1,4]
"alpha": 1 //叠加层透明度
//图片也可以增加w、h属性,会导致图片强制拉伸,可能产生比例变化
},
{
"type": "mask", //叠加类型为马赛克
"enable": true, //显示该叠加层
"content": "16", //马赛克粒度,8/16/32/64
"x": 0.4, //叠加层坐标[0,1],相对于整个图像
"y": 0.4, //同上
"w": 0.2, //同上
"h": 0.2 //同上
},
{
"type": "border", //叠加类型为边框
"x": "0.483", //叠加层坐标[0,1],相对于整个图像
"y": "0.508", //同上
"h": "0.197", //同上
"w": "0.304", //同上
"enable": true, //显示该叠加层
"color": "#000000", //边框颜色,RGB
"alpha": 1, //叠加层透明度
"border": 7 //边框宽度,像素
},
{
"type": "rect", //叠加类型为矩形
"x": "0.097", //叠加层坐标[0,1],相对于整个图像
"y": "0.104", //同上
"h": "0.261", //同上
"w": "0.208", //同上
"enable": true, //显示该叠加层
"color": "#000000", //矩形颜色,RGB
"alpha": 1 //叠加层透明度
}
]
},
…………
],
"status": "success",
"msg": "执行完成"
}
3.27 设置水印配置参数 /link/overlay/set_overlay_confs
请求类型: POST
参数
参数类型 | 描述 |
---|---|
string | 参数为JsonArray字符串,示例如下表 |
参数示例
[
{
"id":0,
"overlay": [
{
"alpha": 1,
"color": "#669900",
"content": "Overlay Text",
"enable": true,
"font": "/link/res/font.ttf",
"move": -1,
"scale": 2.2,
"type": "text",
"w": 0.515,
"x": 0.1,
"y": 0.136
},
…………
]
},
ChnObject,
ChnObject,
ChnObject,
…………
]
ChnObject
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
id | int | 是 | 通道id |
overlay | array | 是 | 水印集合,集合内为水印对象,可以为文字水印,图像水印,时间水印,马赛克水印,边框水印,矩形水印共6种,6种水印可以自由组合和重复组合,但是同一个视频通道使用的水印个数不能超过8个,不同水印可选参数如下 |
TextObject(文字水印)
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
type | string | 是 | 水印类型,文字水印类型值为text |
enable | bool | 是 | 是否显示该叠加层 |
font | string | 是 | 字体文件绝对路径 |
content | string | 是 | 文字内容,最多支持250个字 |
x | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
y | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
scale | double | 是 | 文字相对大小,不同的字体表现不同,[0.1,4] |
color | string | 是 | 文字颜色,RGBA,留空表示透明,例如:#669900 |
bgColor | string | 是 | 文字背景颜色,RGBA,留空表示透明,例如:#669900 |
move | int | 是 | 负数向左滚动,正数向右滚动,0静止,数值越大速度越快 |
alpha | double | 是 | 叠加层透明度 |
w | double | 是 | 叠加层宽度,主要用于限制滚动范围 |
TimeObject(时间水印)
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
type | string | 是 | 水印类型,时间水印类型值为time |
enable | bool | 是 | 是否显示该叠加层 |
font | string | 是 | 字体文件绝对路径 |
content | string | 是 | 时间格式,如yyyy年MM月dd日 hh:mm:ss |
x | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
y | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
scale | double | 是 | 文字相对大小,不同的字体表现不同,[0.1,4] |
color | string | 是 | 文字颜色,RGBA,留空表示透明,例如:#669900 |
bgColor | string | 是 | 文字背景颜色,RGBA,留空表示透明,例如:#669900 |
alpha | double | 是 | 叠加层透明度 |
PicObject(图像水印)
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
type | string | 是 | 水印类型,图像水印类型值为pic |
enable | bool | 是 | 是否显示该叠加层 |
content | string | 是 | 图片绝对路径 |
x | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
y | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
scale | double | 是 | 文字相对大小,不同的字体表现不同,[0.1,4] |
alpha | double | 是 | 叠加层透明度 |
MaskObject(马赛克水印)
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
type | string | 是 | 水印类型,马赛克水印类型值为mask |
enable | bool | 是 | 是否显示该叠加层 |
content | string | 是 | 马赛克颗粒,可选值8 16 32 64 |
x | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
y | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
w | double | 是 | 叠加层宽度[0,1],相对于整个图像,图像左上角为[0,0] |
h | double | 是 | 叠加层高度[0,1],相对于整个图像,图像左上角为[0,0] |
BorderObject(边框水印)
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
type | string | 是 | 水印类型,边框水印类型值为border |
enable | bool | 是 | 是否显示该叠加层 |
x | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
y | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
w | double | 是 | 叠加层宽度[0,1],相对于整个图像,图像左上角为[0,0] |
h | double | 是 | 叠加层高度[0,1],相对于整个图像,图像左上角为[0,0] |
color | string | 是 | 边框颜色,RGBA,留空表示透明 例如:#669900 |
alpha | double | 是 | 叠加层透明度 |
border | int | 是 | 边框宽度,像素 |
RectObject(矩形水印)
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
type | string | 是 | 水印类型,矩形水印类型值为rect |
enable | bool | 是 | 是否显示该叠加层 |
x | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
y | double | 是 | 叠加层坐标[0,1],相对于整个图像,图像左上角为[0,0] |
w | double | 是 | 叠加层宽度[0,1],相对于整个图像,图像左上角为[0,0] |
h | double | 是 | 叠加层高度[0,1],相对于整个图像,图像左上角为[0,0] |
color | string | 是 | 边框颜色,RGBA,留空表示透明 例如:#669900 |
alpha | double | 是 | 叠加层透明度 |
响应
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.28 获取预设的所有布局信息 /link/layout/get_deflay_confs
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": [
{
"id": 0, //布局id
"name": "9宫格" //布局名称
},
{
"id": 1,
"name": "4分屏"
},
{
"id": 2,
"name": "1+2"
},
{
"id": 3,
"name": "画中画"
},
{
"id": 4,
"name": "单画面"
},
{
"id": 5,
"name": "上下"
}
],
"status": "success",
"msg": "执行完成"
}
3.29 获取使用的视频布局、混音信息 /link/layout/get_layout_confs
请求类型:GET / POST
参数
参数名 | 字段类型 | 描述 |
---|---|---|
无 | 无 | 无 |
响应
{
"data": {
"srcV": [ //视频布局内使用的视频通道id,-1为占位符,表示该位置没有切入任何输入源
"0",
"-1",
"-1",
"-1"
],
"srcA": [ //音频混音使用的视频通道id
"0"
],
"curLayId": 1, //当前正在使用的布局id
"curLayName": "4分屏" //当前正在使用的布局名
},
"status": "success",
"msg": "执行完成"
}
3.30 视频布局切换、音频混音 /link/layout/set_layout_confs
请求类型: GET / POST
参数
属性名 | 字段类型 | 是否必传 | 描述 |
---|---|---|---|
layId | int | 否 | 使用的布局id |
srcV | array | 否 | 在布局中切入的视频通道ID,”-1”为占位符 |
srcA | array | 否 | Video channel id used for audio mixing |
parameter example
{
"layId": 1, //使用的布局id
"srcV" : ["1","2","3","-1"], // 切入的视频通道id,-1表示该位置不切入任何输入源
"srcA" : ["1"] //音频混音使用的视频通道id
}
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.31 Get HDMI, VGA output configuration information/link/output/get_output_confs
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": {
"output": {
//HDMI 输出参数
"enable": false, // 是否启用HDMI输出
"lowLatency": false, //是否开启低延时
"output": "1080P60", //输出分辨率
"rotate": 0, //旋转0 90 180 270
"src": 6, //输出的视频通道id
"type": "hdmi", // 类型
"ui": true //是否输出ui(个人开发的UI程序)
},
"output2": {
//VGA 输出参数,同HDMI
"enable": false,
"lowLatency": false,
"output": "1080P60",
"rotate": 0,
"src": 0,
"type": "vga",
"ui": false
}
},
"status": "success",
"msg": "执行完成"
}
3.32 Set HDMI, VGA output configuration information/link/output/set_output_confs
Request type: GET / POST
parameters
attribute name | Field Type | Is it mandatory | describe |
---|---|---|---|
output | OutObject | no | HDMI output configuration |
output2 | OutObject | no | VGA output configuration |
OutObject
attribute name | Field Type | Is it mandatory | describe |
---|---|---|---|
enable | bool | no | Whether to enable the output |
lowLatency | bool | no | Whether to enable low latency |
output | string | no | Output resolution 1080P60 1080I60 1080P50 1080I50 1080P30 720P60 720P50 |
rotate | int | no | to rotate |
src | int | no | The video channel id used for output |
ui | bool | no | Whether to output ui (personally developed UI program) |
parameter example
{
"output": {
"enable": true,
"lowLatency": true,
"output": "1080P60",
"src": 6
},
"output2": {
"enable": false,
"lowLatency": false,
"output": "1080P60",
"src": 0
}
}
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.33 Get recording parameters/link/record/get_record_confs
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": {
"chns": [ //启动录制时,录制的视频通道id
"0",
"2"
],
"mp4": true, //是否录制mp4
"flv": false, //是否录制flv
"mkv": false, //是否录制mkv
"mov": false, //是否录制mov
"ts": false //是否录制ts
},
"status": "success",
"msg": "执行完成"
}
3.34 Set global recording parameters/link/record/set_record_confs
Request type: GET / POST
parameters
attribute name | Field Type | Is it mandatory | describe |
---|---|---|---|
chns | array | no | A collection of video channel ids to record |
mp4 | bool | no | Whether to record mp4 |
flv | bool | no | Whether to record flv |
mkv | bool | no | Whether to record mkv |
mov | bool | no | Whether to record mov |
ts | bool | no | whether to record ts |
parameter example
{
"chns": [
"0",
"2"
],
"mp4": true,
"flv": true,
"mkv": false
}
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}
3.35 Start recording /link/record/start_rec
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": "",
"status": "success",
"msg": "执行完成" //注意:如果没有挂载外部存储设备,会启动录制失败
}
3.36 Stop recording all/link/record/stop_rec
Request type: GET/POST
parameters
parameter name | Field Type | describe |
---|---|---|
none | none | none |
response
{
"data": "",
"status": "success",
"msg": "执行完成"
}