-
Notifications
You must be signed in to change notification settings - Fork 1.5k
如何使用固定播放地址与自动点播
648540858 edited this page Nov 1, 2021
·
3 revisions
WVP提供了一组API,通过鉴权的http请求可以控制流的播放/暂停等功能。
前提: yml配置中必须保证media.rtp.enable=true
路径: {wvp地址}:{wvp端口}/api/play/{动作}/{设备ID}/{通道编号}
动作:
- start 开始点播
- stop 停止点播
- convert 转码
- convertStop 结束转码
- broadcast 语音广播
返回:
如果开始播放请求成功,会返回各种格式的播放路径,这里注意如果你使用docker的形式使用zlm,对zlm的默认端口进行了映射,那么返回路径中的端口号需要修改为映射后的实际端口
{
"code": 0,
"msg": "success",
"data": {
"app": "rtp",
"streamId": "61011300491110000001_61011300491320000001",
"deviceID": "61011300491110000001",
"channelId": "61011300491320000001",
"flv": "http://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.flv",
"https_flv": "https://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.flv",
"ws_flv": "ws://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.flv",
"wss_flv": "wss://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.flv",
"fmp4": "http://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.live.mp4",
"https_fmp4": "https://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.live.mp4",
"ws_fmp4": "ws://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.live.mp4",
"wss_fmp4": "wss://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.live.mp4",
"hls": "http://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001/hls.m3u8",
"https_hls": "https://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001/hls.m3u8",
"ws_hls": "ws://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001/hls.m3u8",
"wss_hls": "wss://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001/hls.m3u8",
"ts": "http://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.live.ts",
"https_ts": "https://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.live.ts",
"ws_ts": "ws://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.live.ts",
"wss_ts": "wss://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.live.ts",
"rtmp": "rtmp://172.18.0.61:1935/rtp/61011300491110000001_61011300491320000001",
"rtmps": "rtmps://172.18.0.61:19350/rtp/61011300491110000001_61011300491320000001",
"rtsp": "rtsp://172.18.0.61:554/rtp/61011300491110000001_61011300491320000001",
"rtsps": "rtsps://172.18.0.61:332/rtp/61011300491110000001_61011300491320000001",
"rtc": "https://172.18.0.61:443/index/api/webrtc?app=rtp&stream=61011300491110000001_61011300491320000001&type=play",
"mediaServerId": "5agyPslsI95Q21er",
"tracks": null,
"transactionInfo": null
}
}
说明:
- 用户使用播放器请求任意格式点播链接,即可发起直播请求
- 如果yml配置
user-settings.auto-apply-play=true
,WVP会自动提供点播,不需要提前调用本接口 - 如果yml配置
user-settings.auto-apply-play=false
(默认),必须先调用本接口启动直播,才能正确发起zlm播放
- 如果yml配置
请求示例:
开始点播 http://172.18.0.56:18080/api/play/start/61011300491110000001/61011300491320000001
停止点播 http://172.18.0.56:18080/api/play/stop/61011300491110000001/61011300491320000001
WVP支持自动点播视频,按照规定格式请求zlm服务器后自动开始播放流。
注意这里的格式实际也是上面的播放接口返回的URL内容
前提: yml配置中必须保证media.rtp.enable=true
路径: {协议}://{zlm地址}:{zlm端口}/rtp/{设备ID}_{通道编号}
协议: flv \ fmp4 \ hls \ rtmp \ rtsp \ ts \ ws_flv \ ws_fmp4 \ ws_hls \ ws_ts
端口: 不同协议端口不同,具体见请求示例
说明:
- 注意这里时zlm的地址,不是WVP的地址。
- 当zlm收到点播请求后,会通过WebHook通知WVP
- 如果yml配置
user-settings.auto-apply-play=true
,WVP会自动进行流操作,播放开始 - 如果yml配置
user-settings.auto-apply-play=false
(默认),WVP不会自动播放,除非用户之前向WVP发出过播放开始请求(见1.播放请求)
- 如果yml配置
请求示例:
"flv": "http://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.flv"
"https_flv": "https://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.flv"
"ws_flv": "ws://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.flv"
"wss_flv": "wss://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.flv"
"fmp4": "http://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.live.mp4"
"https_fmp4": "https://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.live.mp4"
"ws_fmp4": "ws://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.live.mp4"
"wss_fmp4": "wss://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.live.mp4"
"hls": "http://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001/hls.m3u8"
"https_hls": "https://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001/hls.m3u8"
"ws_hls": "ws://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001/hls.m3u8"
"wss_hls": "wss://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001/hls.m3u8"
"ts": "http://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.live.ts"
"https_ts": "https://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.live.ts"
"ws_ts": "ws://172.18.0.61:6080/rtp/61011300491110000001_61011300491320000001.live.ts"
"wss_ts": "wss://172.18.0.61:443/rtp/61011300491110000001_61011300491320000001.live.ts"
"rtmp": "rtmp://172.18.0.61:1935/rtp/61011300491110000001_61011300491320000001"
"rtmps": "rtmps://172.18.0.61:19350/rtp/61011300491110000001_61011300491320000001"
"rtsp": "rtsp://172.18.0.61:554/rtp/61011300491110000001_61011300491320000001"
"rtsps": "rtsps://172.18.0.61:332/rtp/61011300491110000001_61011300491320000001"
"rtc": "https://172.18.0.61:443/index/api/webrtc?app=rtp&stream=61011300491110000001_61011300491320000001&type=play"