目录1、背景说明2、配置拉转视频流2.1 RTSP规则2.2 通道配置2.2 启用通道2.3、查看播放3、视频集成方式4、分享页面集成5、视频流地址集成5.1、直播流地址(页面查看获取)5.2、直播流地址(接口调用获取)5.2.1、接口服务地址说明5.2.2、获取通道直播链接接口5.2.3、获取HTTP-FLV播放地址示例5.2.3.1、接口调用示例5.2.3.2 接口返回示例5.2.4、获取WS-FLV播放地址示例5.2.4.1、接口调用示例5.2.4.2、接口返回示例5.2.5、获取WebRTC播放地址示例5.2.5.1、接口调用示例5.2.5.2、接口返回示例5.2.6、获取RTMP播放地址示例5.2.6.1、接口调用示例5.2.6.2、接口返回示例5.2.7、获取HLS播放地址示例5.2.7.1、接口调用示例5.2.7.2、接口返回示例5.2.8、RTSP5.2.8.1、开启RTSP5.2.8.2、获取RTSP播放地址示例5.2.8.2.1、接口调用示例5.2.8.2.2、接口返回示例5.3、直播流地址(静态拼接获取)5.3.1、HTTP端口直播流地址格式5.3.2、HTTPS端口直播流地址格式5.3.3、关闭静态流地址播放6、接口调用相关问题7、RTSP/HLS/FLV/RTMP拉流Onvif流媒体服务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 通道配置点击通道配置进入通道配置页,可以选择需要配置的通道右上角的设置按钮,具体配置接入详见2.2 启用通道勾选 是否启用,点击 【确定】2.3、查看播放视频广场找到相应通道,点击播放3、视频集成方式分享页面集成直接集成包含播放器的页面到业务系统中去,如 iframe 方式集成页面视频流地址集成通过接口或其它方式获取视频流的地址,设置到web播放器|APP播放器|PC播放器中,进行播放。可以使用LivePlayer.js H5播放器。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 参数:channel 通道号aspect 配置只显示视频播放区域, 同时指定宽高比, 可选, wxh, 例如 640×360, 即16:9, 当 aspect=fullscreen 时, 整页显示播放器share 是否显示分享, 可选, yes/no, 默认值为 yesfluent 是否以流畅模式播放, 可选, yes/no, 默认值为 yesautoplay 是否自动播放, 可选, yes/no, 默认值为 yescontrols 是否显示播放器控制栏, 可选, yes/no, 默认值为 yesstretch 是否拉伸显示, 可选, yes/no, 默认值为 nomuted 是否播放器静音, 可选, yes/no, 默认值为 yesprotocol 播放流格式, 可选, rtmp/hls/flv/ws_flv, 默认 auto check5、视频流地址集成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、获取通道直播链接接口通道相关 – 获取通道直播链接5.2.3、获取HTTP-FLV播放地址示例5.2.3.1、接口调用示例http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=flv5.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-flv5.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=webrtc5.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=rtmp5.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=hls5.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、RTSP5.2.8.1、开启RTSPRTSP输出,默认是关闭的,开启需要在基础配置界面配置 RTSP端口(默认554),需要在服务器上开放此端口 TCP5.2.8.2、获取RTSP播放地址示例5.2.8.2.1、接口调用示例http://192.168.2.135:10800/api/v1/getchannelstream?channel=1&protocol=rtsp5.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_{通道号}.flvWS_FLV: ws://{ip}:{port}/ws-flv/hls/stream_{通道号}.flvHLS: http://{ip}:{port}/hls/stream_{通道号}/stream_{通道号}_live.m3u8RTMP: 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_{通道号}.flvWS_FLV: ws://{ip}:{port}/ws-flv/hls/stream_{通道号}.flvHLS: http://{ip}:{port}/hls/stream_{通道号}/stream_{通道号}_live.m3u8RTMP: 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=06、接口调用相关问题LiveNVROnvif|RTSP流媒体服务中二次开发接口jquery调用示例
本文出自快速备案,转载时请注明出处及相应链接。