LiveNVR监控流媒体Onvif_RTSP常见问题-关于集成直播页面如何将监控视频画面集成到业务系统?
@
1、监控视频画面集成
如何将LiveNVR的安防监控的视频直播,集成到您自己的的业务系统页面上。一般有2钟方式,一个是将播放页面直接iframe的方式嵌套再在自己的业务系统页面中。另一种是取到直播流地址塞给页面播放器播放。
2、iframe播放页面集成(方式一)
为方便客户在网页中集成播放功能, 我们单独提供了可供 HTML iframe 集成的分享页 详见, 形如:
http://ip:port/play.html?channel=xx
其中 URL 参数:
-
channel 通道号
-
aspect 配置只显示视频播放区域, 同时指定宽高比, 可选, wxh, 例如 640x360, 即16:9, 当 aspect=fullscreen 时, 整页显示播放器
-
share 是否显示分享, 可选, yes/no, 默认值为 yes
-
fluent 是否以流畅模式播放, 可选, yes/no, 默认值为 yes
-
autoplay 是否自动播放, 可选, yes/no, 默认值为 yes
-
controls 是否显示播放器控制栏, 可选, yes/no, 默认值为 yes
-
stretch 是否拉伸显示, 可选, yes/no, 默认值为 no
-
muted 是否播放器静音, 可选, yes/no, 默认值为 yes
-
protocol 播放流格式, 可选, rtmp/hls/flv/ws_flv, 默认 auto check
2、直播流地址获取(方式二)
2.1、HTTP接口获取
2.1.1、接口说明
http://192.168.2.135:10800 是示例的ip及端口,更换成自己部署的LiveNVR的ip及端口
2.1.2、获取HTTP-FLV流地址
2.1.2.1、接口调用示例
http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=flv
2.1.2.2、接口返回示例
获取接口返回的,URL字段,前面拼接上服务的ip和端口
{
"LiveQing": {
"Header": {
"CSeq": "1",
"Version": "v1",
"MessageType": "MSG_SC_SERVER_GET_CHANNEL_STREAM_ACK",
"ErrorNum": "200",
"ErrorString": "Success OK"
},
"Body": {
"AudioEnable": false,
"ChannelName": "拉取 FLV",
"DeviceType": "FLV",
"NumOutputs": 0,
"OSD": "拉取 FLV",
"Ondemand": true,
"Recording": false,
"SnapURL": "/snap/channel_1.jpg?t=1615518655678277862",
"SourceAudioCodecName": "aac",
"SourceAudioSampleRate": 8000,
"SourceVideoCodecName": "h264",
"SourceVideoFrameRate": 25,
"SourceVideoHeight": 576,
"SourceVideoWidth": 704,
"URL": "/flv/hls/stream_1.flv"
}
}
}
2.1.3、获取WS-FLV流地址
2.1.3.1、接口调用示例
http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=ws-flv
2.1.3.2、接口返回示例
获取接口返回的,URL字段
{
"LiveQing": {
"Header": {
"CSeq": "1",
"Version": "v1",
"MessageType": "MSG_SC_SERVER_GET_CHANNEL_STREAM_ACK",
"ErrorNum": "200",
"ErrorString": "Success OK"
},
"Body": {
"AudioEnable": false,
"ChannelName": "拉取 FLV",
"DeviceType": "FLV",
"NumOutputs": 1,
"OSD": "拉取 FLV",
"Ondemand": true,
"Recording": false,
"SnapURL": "/snap/channel_1.jpg?t=1615519865764505509",
"SourceAudioCodecName": "aac",
"SourceAudioSampleRate": 8000,
"SourceVideoCodecName": "h264",
"SourceVideoFrameRate": 25,
"SourceVideoHeight": 576,
"SourceVideoWidth": 704,
"URL": "ws://192.168.2.135:10800/ws-flv/hls/stream_1.flv"
}
}
}
2.1.4、获取WebRTC流地址
2.1.4.1、接口调用示例
http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=webrtc
2.1.4.2、接口返回示例
获取接口返回的,URL字段
{
"LiveQing": {
"Header": {
"CSeq": "1",
"Version": "v1",
"MessageType": "MSG_SC_SERVER_GET_CHANNEL_STREAM_ACK",
"ErrorNum": "200",
"ErrorString": "Success OK"
},
"Body": {
"AudioEnable": false,
"ChannelName": "拉取 FLV",
"DeviceType": "FLV",
"NumOutputs": 1,
"OSD": "拉取 FLV",
"Ondemand": true,
"Recording": false,
"SnapURL": "/snap/channel_1.jpg?t=1615519865764505509",
"SourceAudioCodecName": "aac",
"SourceAudioSampleRate": 8000,
"SourceVideoCodecName": "h264",
"SourceVideoFrameRate": 25,
"SourceVideoHeight": 576,
"SourceVideoWidth": 704,
"URL": "webrtc://192.168.2.135:10800/rtc/stream_1"
}
}
}
2.1.5、获取RTMP流地址
2.1.5.1、接口调用示例
http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=rtmp
2.1.5.2、接口返回示例
获取接口返回的,URL字段,服务需要开启对应的rtmp端口 TCP
{
"LiveQing": {
"Header": {
"CSeq": "1",
"Version": "v1",
"MessageType": "MSG_SC_SERVER_GET_CHANNEL_STREAM_ACK",
"ErrorNum": "200",
"ErrorString": "Success OK"
},
"Body": {
"AudioEnable": false,
"ChannelName": "拉取 FLV",
"DeviceType": "FLV",
"NumOutputs": 1,
"OSD": "拉取 FLV",
"Ondemand": true,
"Recording": false,
"SnapURL": "/snap/channel_1.jpg?t=1615519865764505509",
"SourceAudioCodecName": "aac",
"SourceAudioSampleRate": 8000,
"SourceVideoCodecName": "h264",
"SourceVideoFrameRate": 25,
"SourceVideoHeight": 576,
"SourceVideoWidth": 704,
"URL": "rtmp://192.168.2.135:10935/hls/stream_1"
}
}
}
2.1.6、获取HLS流地址
2.1.6.1、接口调用示例
http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=hls
2.1.6.2、接口返回示例
获取接口返回的,URL字段,前面拼接上服务的ip和端口
{
"LiveQing": {
"Header": {
"CSeq": "1",
"Version": "v1",
"MessageType": "MSG_SC_SERVER_GET_CHANNEL_STREAM_ACK",
"ErrorNum": "200",
"ErrorString": "Success OK"
},
"Body": {
"AudioEnable": false,
"ChannelName": "拉取 FLV",
"DeviceType": "FLV",
"NumOutputs": 1,
"OSD": "拉取 FLV",
"Ondemand": true,
"Recording": false,
"SnapURL": "/snap/channel_1.jpg?t=1615519865764505509",
"SourceAudioCodecName": "aac",
"SourceAudioSampleRate": 8000,
"SourceVideoCodecName": "h264",
"SourceVideoFrameRate": 25,
"SourceVideoHeight": 576,
"SourceVideoWidth": 704,
"URL": "/hls/stream_1/stream_1_live.m3u8"
}
}
}
2.1.7、RTSP
2.1.7.1、开启RTSP
RTSP输出,默认是关闭的,开启需要在基础配置界面配置 RTSP端口(默认554),需要在服务器上开放此端口 TCP
2.1.7.2、获取RTSP流地址
2.1.7.2.1、接口调用示例
http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=rtsp
2.1.7.2、接口返回示例
获取接口返回的,URL字段
{
"LiveQing": {
"Header": {
"CSeq": "1",
"Version": "v1",
"MessageType": "MSG_SC_SERVER_GET_CHANNEL_STREAM_ACK",
"ErrorNum": "200",
"ErrorString": "Success OK"
},
"Body": {
"AudioEnable": false,
"ChannelName": "拉取 FLV",
"DeviceType": "FLV",
"NumOutputs": 1,
"OSD": "拉取 FLV",
"Ondemand": true,
"Recording": false,
"SnapURL": "/snap/channel_1.jpg?t=1615519865764505509",
"SourceAudioCodecName": "aac",
"SourceAudioSampleRate": 8000,
"SourceVideoCodecName": "h264",
"SourceVideoFrameRate": 25,
"SourceVideoHeight": 576,
"SourceVideoWidth": 704,
"URL": "rtsp://192.168.2.135:554/stream_3"
}
}
}
2.2、浏览器F12查看播放地址
2.3、静态流地址拼接
不调用开始直播可以获取播放地址吗?可以的,LiveNVR支持流地址播放直接启动通道拉流,配置规则如下:
2.3.1、HTTP端口直播流地址格式
-
WEBRTC: webrtc://{ip}:{port}/rtc/stream_
-
FLV: http://{ip}:{port}/flv/hls/stream_{通道号}.flv
-
WS_FLV: ws://{ip}:{port}/ws-flv/hls/stream_{通道号}.flv
-
HLS: http://{ip}:{port}/hls/stream_{通道号}/stream_{通道号}_live.m3u8
-
RTMP: rtmp://{ip}:{port}/hls/stream_
-
RTSP: rtsp://{ip}:{port}/stream_
2.3.2、HTTPS端口直播流地址格式
-
WEBRTC: webrtc://{ip}:{port}/rtc/stream_
-
FLV: http://{ip}:{port}/flv/hls/stream_{通道号}.flv
-
WS_FLV: ws://{ip}:{port}/ws-flv/hls/stream_{通道号}.flv
-
HLS: http://{ip}:{port}/hls/stream_{通道号}/stream_{通道号}_live.m3u8
-
RTMP: rtmp://{ip}:{port}/hls/stream_
-
RTSP: rtsp://{ip}:{port}/stream_
2.3.3、关闭静态流地址播放
livenvr.ini ->[base_config]->allow_stream_start_by_url=0 , 默认是开启此功能的,配置后重启LiveNVR服务
[base_config]
allow_stream_start_by_url=0