视频源管理模块,解码器核心模块,用户需要先添加编码源后才能进行解码播放/流服务等功能。
包含:获取视频源列表、添加、修改、删除等接口。
文章目录
获取视频源列表
API说明
获取视频源列表。
Request
- Method: GET/POST
- URL:
source/get.json
- Headers:
- 提交参数: 无
Response
- Body:
{`` "result": "ok",`` "data": [`` {`` "manual_url": "srt://192.168.4.34:55123",`` "time_position": "left_top",`` "id": "MANUAL.2",`` "status": "view_pull",`` "srtStatus": {`` "liveStatus": "Connected",`` "srtMode": "caller",`` "rtt": 0.412,`` "byteRecvTotal": "11722615200",`` "pktRcvRetrans": 0,`` "pktRcvLoss": 0,`` "bandwidth": 0.096,`` "pktRcvLossTotal": 389`` },`` "name_position": "left_top",`` "address": "srt://192.168.4.34:55123",`` "imgUrl": "",`` "resolution": "[email protected]",`` "origin": "manual",`` "type": "srt",`` "bitrate": 88,`` "name": "555566",`` "buffer": "live:200:200:500:0:0"`` },`` {`` "manual_url": "rtsp://192.168.4.200:5543/ch013",`` "time_position": "left_top",`` "id": "MANUAL.25",`` "status": "pull",`` "buffer": "live:200:200:500:0:0",`` "origin": "manual",`` "src": "rtsp://192.168.4.200:5543/ch013",`` "address": "rtsp://192.168.4.200:5543/ch013",`` "imgUrl": "",`` "bitrate": 9952,`` "type": "rtsp",`` "name": "888888",`` "resolution": "[email protected]",`` "name_position": "left_top"`` }`` ]``}
- 返回说明:
字段 | 类型 | 说明 |
---|---|---|
id | 字符串 | 解码源ID,手动添加源以MANUAL 开头,如:MANUAL.1 |
name | 字符串 | 编码源名称,用户自定义 |
resolution | 字符串 | 分辨率@帧率,如:[email protected] |
manual_url | 字符串 | 视频源地址,如:rtsp://192.168.4.200:5543/ch013 |
src | 字符串 | 视频来源地址,如:rtsp://192.168.4.200:5543/ch013 |
status | 字符串 | 解码源当前工作状态: view_pull 显示/推流、pull 推流、view 显示、on 在线、off 离线 reconnecting 重连中、connecting 正在连接、error 异常 |
buffer | 字符串 | 连接缓存参数信息,如live:200:200:500:0:0 |
bitrate | 数值 | 码流大小,单位K,比如:2992 |
type | 字符串 | 解码源类型:取值:rtmp、rtsp、rtmps、rtp、udp、http、srt |
name_position | 字符串 | |
imgUrl | 字符串 | 图像 |
time_position | 字符串 | |
address | 字符串 | 视频来源地址,如:rtsp://192.168.4.200:5543/ch013 |
origin | 字符串 |
测试调用:
http://192.168.2.123/api/source/get.json
添加视频源
API说明
添加视频源并配置地址、缓冲参数、连接参数等信息。
Request
- Method: POST(**只能POST方法)**
- URL:
source/add.json
- Headers:
- 提交参数:
字段 | 类型 | 说明 |
---|---|---|
name | 字符串 | 解码源名称(**必需参数)** |
main | InfoObject[] | 主码流参数(**必需参数)** InfoObject各种视频格式不相同,详情参考下面各个格式的参数列表 |
sub | InfoObject[] | 子码流参数(**必需参数)** |
rtsp InfoObject
字段 | 类型 | 说明 |
---|---|---|
manual_url | string | 解码源地址(**必需参数)**,如:rtsp://192.168.3.101/ch01 |
buffer | string | 缓冲配置参数(**必需参数)**,取值范围: 0ms 时参数:live:0:0:0:0:0 50ms 时参数:live:50:50:200:0:0 120ms时参数:live:120:120:300:0:0 200ms时参数:live:200:200:500:0:0 500ms时参数:live:500:500:800:0:0 1s 时参数:live:1000:1000:1500:0:0 |
trans_mode | string | 连接参数(**必需参数),TCP 或 UDP** |
user | string | 解码源连接用户名、根据视频源有无用户认证进行配置 |
password | string | 解码源连接密码、根据视频源有无用户认证进行配置 |
type | string | 源类型 如: rtsp |
connect_speed | string | 取值范围:0-3、数值:0极低、1较低、2正常、3较高 |
audio_sync_compst | number | 音频同步补偿值: 范围 -3000~3000 单位ms |
rtsp参考格式:
{`` "name":"sy",`` "main":{`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtsp://192.168.0.1:554/ch01",`` "trans_mode":"TCP",`` "user":"",`` "password":"",`` "type":"rtsp",`` "connect_speed":2,`` "audio_sync_compst":0`` },`` "sub":{`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtsp://",`` "trans_mode":"TCP",`` "user":"",`` "password":"",`` "type":"rtsp",`` "connect_speed":2,`` "audio_sync_compst":0`` }``}
rtmp/rtmps InfoObject
字段 | 类型 | 说明 |
---|---|---|
manual_url | string | 解码源地址(**必需参数)**,如:rtmp://192.168.2.196 |
buffer | string | 缓冲配置参数(**必需参数)**,取值范围: 0ms 时参数:live:0:0:0:0:0 50ms 时参数:live:50:50:200:0:0 120ms时参数:live:120:120:300:0:0 200ms时参数:live:200:200:500:0:0 500ms时参数:live:500:500:800:0:0 1s 时参数:live:1000:1000:1500:0:0 |
user | string | 解码源连接用户名、根据视频源有无用户认证进行配置 |
password | string | 解码源连接密码、根据视频源有无用户认证进行配置 |
type | string | 源类型 如: rtmp/rtmps |
connect_speed | number | 取值范围:0-3、数值:0极低、1较低、2正常、3较高 |
audio_sync_compst | number | 音频同步补偿值: 范围 -3000~3000 单位ms |
rtmp/rtmps参考格式:
{`` "name":"sy",`` "main":{`` "audio_sync_compst":0,`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtmp://192.168.0.1",`` "user":"",`` "password":"",`` "type":"rtmp",`` "connect_speed":2`` },`` "sub":{`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtmp://",`` "user":"",`` "password":"",`` "type":"rtmp",`` "connect_speed":2,`` "audio_sync_compst":0`` }``}
rtp InfoObject
字段 | 类型 | 说明 |
---|---|---|
manual_url | string | 解码源地址(**必需参数)**,如:rtmp://192.168.2.196 |
buffer | string | 缓冲配置参数(**必需参数)**,取值范围: 0ms 时参数:live:0:0:0:0:0 50ms 时参数:live:50:50:200:0:0 120ms时参数:live:120:120:300:0:0 200ms时参数:live:200:200:500:0:0 500ms时参数:live:500:500:800:0:0 1s 时参数:live:1000:1000:1500:0:0 |
type | string | 源类型 如: rtp |
connect_speed | number | 取值范围:0-3、数值:0极低、1较低、2正常、3较高 |
audio_sync_compst | number | 音频同步补偿值: 范围 -3000~3000 单位ms |
video_port | number | 视频接收端口 |
audio_port | number | 音频接收端口 |
audio_codec | string | 音频CODEC([PT,]CODEC[/时间戳单位], 如96,H264/90000) |
video_codec | string | 视频CODEC([PT,]CODEC[/时间戳单位], 如96,H264/90000) |
bindNetwork | string | 绑定网络 参考值:auto |
rtp参考格式:
{`` "name":"sy",`` "main":{`` "audio_sync_compst":0,`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtp://192.168.43.56:1026",`` "type":"rtp",`` "connect_speed":2,`` "audio_port":1,`` "video_port":1,`` "audio_codec":"",`` "video_codec":"",`` "bindNetwork":"audo"`` `` },`` "sub":{`` "audio_sync_compst":0,`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtp://",`` "type":"rtp",`` "connect_speed":2,`` "audio_port":1,`` "video_port":1,`` "audio_codec":"",`` "video_codec":"",`` "bindNetwork":"audo"`` }``}
udp/http/https InfoObject
字段 | 类型 | 说明 |
---|---|---|
manual_url | string | 解码源地址(**必需参数)**,如:udp://192.168.43.56:7423 |
buffer | string | 缓冲配置参数(**必需参数)**,取值范围: 0ms 时参数:live:0:0:0:0:0 50ms 时参数:live:50:50:200:0:0 120ms时参数:live:120:120:300:0:0 200ms时参数:live:200:200:500:0:0 500ms时参数:live:500:500:800:0:0 1s 时参数:live:1000:1000:1500:0:0 |
type | string | 源类型 如: udp/http/https |
connect_speed | number | 取值范围:0-3、数值:0极低、1较低、2正常、3较高 |
audio_sync_compst | number | 音频同步补偿值: 范围 -3000~3000 单位ms |
udp/http/https 参考格式
{`` "name":"sy",`` "main":{`` "audio_sync_compst":0,`` "buffer":"live:200:200:500:0:0",`` "manual_url":"udp://192.168.43.56:7423",`` "type":"udp",`` "connect_speed":2`` `` },`` "sub":{`` "audio_sync_compst":0,`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtp://",`` "type":"udp",`` "connect_speed":2`` }``}
srt InfoObject
字段 | 类型 | 说明 |
---|---|---|
manual_url | string | 解码源地址(**必需参数)**,如:srt://192.168.43.80:1025 |
buffer | string | 缓冲配置参数(**必需参数)**,取值范围: 0ms 时参数:live:0:0:0:0:0 50ms 时参数:live:50:50:200:0:0 120ms时参数:live:120:120:300:0:0 200ms时参数:live:200:200:500:0:0 500ms时参数:live:500:500:800:0:0 1s 时参数:live:1000:1000:1500:0:0 |
type | string | 源类型 如: srt |
connect_speed | number | 取值范围:0-3、数值:0极低、1较低、2正常、3较高 |
audio_sync_compst | number | 音频同步补偿值: 范围 -3000~3000 单位ms |
address | string | 公网地址(Listener模式下不生效) |
connectionMode | string | 握手模式(Listener,Caller,Rendezvous) |
showAdvanced | string | 是否显示高级选项 “1”为显示,"0"为不显示 |
srt_streamid | string | SRT流ID |
encryption | string | 加密方式,默认为none,可选值: AES-128、AES-192、AES-256 |
passphrase | string | AES密钥,当encryption不为none时必填 |
bandwidth | number | 带宽开销,单位%,默认为25,可填范围5-100 |
payloadSize | number | 载荷大小,默认1316,范围0-1456 |
listenerPort | number | 端口号,范围1025-65535 |
latency | number | 传输延迟,默认为125,范围0-5000m,单位ms |
srt 参考格式
{`` "name":"sy",`` "main":{`` "audio_sync_compst":0,`` "buffer":"live:200:200:500:0:0",`` "manual_url":"srt://192.168.43.80:1025",`` "type":"srt",`` "connect_speed":2,`` "address":"192.168.43.80",`` "connectionMode":"Caller",`` "showAdvanced":"0",`` "srt_streamid":"",`` "encryption":"none",`` "passphrase":"",`` "bandwidth":25,`` "payloadSize":1316,`` "listenerPort":1025,`` "latency":125`` `` },`` "sub":{`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtsp://",`` "trans_mode":"TCP",`` "user":"",`` "password":"",`` "type":"rtsp",`` "connect_speed":2,`` "audio_sync_compst":0`` }``}
ndi InfoObject
字段 | 类型 | 说明 |
---|---|---|
manual_url | string | 解码源地址(**必需参数)**,如:ndi://192.168.2.196:5960 |
buffer | string | 缓冲配置参数(**必需参数)**,取值范围: 0ms 时参数:live:0:0:0:0:0 50ms 时参数:live:50:50:200:0:0 120ms时参数:live:120:120:300:0:0 200ms时参数:live:200:200:500:0:0 500ms时参数:live:500:500:800:0:0 1s 时参数:live:1000:1000:1500:0:0 |
type | string | 源类型 如: ndi |
preview_mode | string | 码流,"0"为主码流,"1"为子码流 |
audio_sync_compst | number | 音频同步补偿值: 范围 -3000~3000 单位ms |
ndi_name | string | NDI名称(**必需参数)** |
ndi参考格式
{`` "name":"sss",`` "main":{`` "audio_sync_compst":0,`` "buffer":"live:200:200:500:0:0",`` "manual_url":"ndi://192.168.43.80:5966",`` "type":"ndi",`` "preview_mode":"1",`` "ndi_name":"xxx"`` `` },`` "sub":{`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtsp://",`` "trans_mode":"TCP",`` "user":"",`` "password":"",`` "type":"rtsp",`` "connect_speed":2,`` "audio_sync_compst":0`` }``}
Rtmp Server InfoObject
字段 | 类型 | 说明 |
---|---|---|
manual_url | string | 解码源地址(**必需参数)**,如:rtmp://192.168.43.56:1935/live/zzz |
buffer | string | 缓冲配置参数(**必需参数)**,取值范围: 0ms 时参数:live:0:0:0:0:0 50ms 时参数:live:50:50:200:0:0 120ms时参数:live:120:120:300:0:0 200ms时参数:live:200:200:500:0:0 500ms时参数:live:500:500:800:0:0 1s 时参数:live:1000:1000:1500:0:0 |
type | string | 源类型 如: rtmp_server |
connect_speed | number | 取值范围:0-3、数值:0极低、1较低、2正常、3较高 |
audio_sync_compst | number | 音频同步补偿值: 范围 -3000~3000 单位ms |
rtmp_server_application | string | live |
rtmp_server_enable | boolean | 启动 true/false |
rtmp_server_port | number | rtmp端口 |
rtmp_server_security | string | 安全选项(token/none) |
rtmp_server_session | string | 会话id |
rtmp_server_token | string | 随机token(拼接到udl后面)当rtmp_server_security为token时必填 |
user | string | 用户名 |
password | string | 密码 |
rtmp server参考格式
{`` "name":"sss",`` "main":{`` "audio_sync_compst":0,`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtmp://192.168.43.56:1935/live/zzz",`` "type":"rtmp_server",`` "connect_speed":"2",`` "rtmp_server_application":"live",`` "rtmp_server_enable":true,`` "rtmp_server_port":1935,`` "rtmp_server_security":"none",`` "rtmp_server_session":"zzz",`` "rtmp_server_token":"",`` "user":"",`` "password":""`` `` },`` "sub":{`` "buffer":"live:200:200:500:0:0",`` "manual_url":"rtsp://",`` "trans_mode":"TCP",`` "user":"",`` "password":"",`` "type":"rtsp",`` "connect_speed":2,`` "audio_sync_compst":0`` }``}
Response
- Body:
{`` result: "ok"``}
修改视频源参数
API说明
修改视频源参数。
Request
- Method: GET/POST
- URL:
source/modify.json
- Headers:
- 提交参数:
字段 | 类型 | 说明 |
---|---|---|
id | 字符串 | 解码源ID(**必需参数)**,如:“MANUAL.6”,可从获取编码源信息接口取得 |
name | 字符串 | 解码源名称(**必需参数)** |
main | InfoObject[] | 主码流参数(**必需参数)** InfoObject各种视频格式不相同,详情2.2章节下面各个格式的参数列表 |
sub | InfoObject[] | 子码流参数(**必需参数)** |
Response
- Body
{`` "result": "ok"``}
测试调用:
2.4 删除视频源
API说明
删除视频源。
若已配置播放或流服务,对应播放窗口和流服务将会解除绑定关系。
Request
- Method: GET/POST
- URL:
source/remove.json
- Headers:
- 提交参数:
字段 | 类型 | 说明 |
---|---|---|
id | 字符串 | 解码源ID(**必需参数)**,如:“MANUAL.6”,可从获取编码源信息接口取得 |
Response
- Body
{`` result: "ok"``}
测试调用:
http://192.168.2.123/api/source/remove.json?id=MANUAL.11