目录

1、背景说明

某些场景下(小区监控、厂区监控等),我们需要接入摄像头,但手头上只能获取到摄像头直播流地址,如RTSP流地址。我们可能需要将视频流发布web页面,可以用浏览器快速无插件的浏览观看。我们可能需要云台操作摄像头。我们可能需要将视频监控的视频流做集中的存储录制。此时我们可以用什么来解决,安防监控摄像头设备的接入呢?

LiveNVR Onvif/RTSP流媒体服务,支持RTSP等其它流拉流接入,支持Onvif协议接入,支持RTMP/HLS/HTTP-FLV/WS-FLV/RTSP/GB28181输出,将传统安防监控设备互联化,无插件直播等。

可接入传统监控行业里面的高清网络摄像机的RTSP直播流,及 RTMP、HTTP-FLV、M3U8等其它直播流,实现互联网直播分发;可分发多种格式流,支持GB28181注册级联到第三方国标平台;同时能实时云端存储、录像计划、检索、时移回放

2、配置拉转视频流

2.1 RTSP规则

大华、海康、宇视、华为等RTSP配置规则

2.2 通道配置

点击通道配置进入通道配置页,可以选择需要配置的通道右上角的设置按钮,具体配置接入详见

LiveNVR直播流地址RTSP(LiveNVR直播流地址RTSP)(1)

LiveNVR直播流地址RTSP(LiveNVR直播流地址RTSP)(2)

2.2 启用通道

勾选 是否启用,点击 【确定】

LiveNVR直播流地址RTSP(LiveNVR直播流地址RTSP)(3)

2.3、查看播放

视频广场找到相应通道,点击播放

LiveNVR直播流地址RTSP(LiveNVR直播流地址RTSP)(4)

3、视频集成方式4、分享页面集成

获取通道分享页面:为方便客户在网页中集成播放功能, 我们单独提供了可供 HTML iframe 集成的分享页 详见, 形如:

http://ip:port/play.html?channel=xx

<!-- 直播 -->

<iframe src="http://ip:port/play.html?channel=1&aspect=fullscreen" allowfullscreen allow="autoplay; fullscreen"></iframe>

其中 URL 参数:

5、视频流地址集成

5.1、直播流地址(页面查看获取)

浏览器跟踪NETWORK

视频广场-》点击 播放, 浏览器可以 f12 打开开发者模式,再查看通道点击播放,然后在 Network 中跟踪到 /api/v1/getchannelstream 接口调用和结果

5.2、直播流地址(接口调用获取)

5.2.1、接口服务地址说明

http://192.168.2.135:10800 是示例的ip及端口,更换成自己部署的LiveNVR的ip及端口

5.2.2、获取通道直播链接接口

通道相关 - 获取通道直播链接

LiveNVR直播流地址RTSP(LiveNVR直播流地址RTSP)(5)

5.2.3、获取HTTP-FLV播放地址示例

5.2.3.1、接口调用示例

http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=flv

5.2.3.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"

}

}

}

5.2.4、获取WS-FLV播放地址示例

5.2.4.1、接口调用示例

http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=ws-flv

5.2.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": "ws://192.168.2.135:10800/ws-flv/hls/stream_1.flv"

}

}

}

5.2.5、获取WebRTC播放地址示例

5.2.5.1、接口调用示例

http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=webrtc

5.2.5.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"

}

}

}

5.2.6、获取RTMP播放地址示例

5.2.6.1、接口调用示例

http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=rtmp

5.2.6.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"

}

}

}

5.2.7、获取HLS播放地址示例

5.2.7.1、接口调用示例

http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=hls

5.2.7.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"

}

}

}

5.2.8、RTSP

5.2.8.1、开启RTSP

RTSP输出,默认是关闭的,开启需要在基础配置界面配置 RTSP端口(默认554),需要在服务器上开放此端口 TCP

LiveNVR直播流地址RTSP(LiveNVR直播流地址RTSP)(6)

5.2.8.2、获取RTSP播放地址示例

5.2.8.2.1、接口调用示例

http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=rtsp

5.2.8.2.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"

}

}

}

5.3、直播流地址(静态拼接获取)

不调用开始直播可以获取播放地址吗?可以的,LiveNVR支持流地址播放直接启动通道拉流,配置规则如下:

5.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_{通道号}

5.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_{通道号}

5.3.3、关闭静态流地址播放

livenvr.ini ->[base_config]->allow_stream_start_by_url=0 , 默认是开启此功能的,配置后重启LiveNVR服务

[base_config]

allow_stream_start_by_url=0

6、接口调用相关问题

LiveNVROnvif|RTSP流媒体服务中二次开发接口jquery调用示例

,