当前位置:网站首页>Real time preview of RTSP video based on webrtc
Real time preview of RTSP video based on webrtc
2022-06-24 01:00:00 【ruochen】
brief introduction
background
Because the project needs , You need to use the camera preview function , The equipment model is Hikvision . The existing one is based on FFmpeg The delay of our solutions is too high , So the final choice of the project is based on this scheme .
programme
The scheme is based on WebRTC Video instant messaging for , It's native support for RTP Decoding protocol , So the delay is very low , Probably 0.2-0.4 About seconds , All other schemes are larger than 1 Second delay .
WebRTC There are requirements for browsers , You can view the supported browsers in the address below .
https://caniuse.com/rtcpeerconnection
image
The following introduction is from Baidu Encyclopedia
WebRTC, The name comes from web instant messaging ( English :Web Real-Time Communication) Abbreviation , Is a web browser to support real-time voice or video dialogue API. It's on 2011 year 6 month 1 Japan open source and in Google、Mozilla、Opera With the support of W3C Recommended standards .
WebRTC Realized video conference based on Web page , The standard is WHATWG agreement , The goal is to provide simple javascript You can achieve real-time communication (Real-Time Communications (RTC)) Ability .
WebRTC The implementation scheme of is in Github There are many , After a series of comparisons and tests , The final choice is to use [webrtc-
streamer](https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2Fmpromonet%2Fwebrtc-
streamer) This project , It's easy to use and more stable .
Getting Started
[webrtc-
streamer](https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2Fmpromonet%2Fwebrtc-
streamer) Not only support for RTSP Stream capture and support for V4L2 And the capture of screen window snapshots .
webrtc-streamer Built in a small HTTP server Come on webrtc Need the relevant interface to support .
The following is how to set it :
Configure the camera
because webrtc Our core library doesn't support h265, So it needs to be set to h264 code .
Log in to the background configuration center of Hikvision camera , stay “ Video and audio ” Make settings under the menu , Then save .
image
Download the latest package
stay github The publishing page selects the corresponding package to download according to the required platform
[https://github.com/mpromonet/webrtc-
streamer/releases](https://links.jianshu.com/go?to=https%3A%2F%2Fgithub.com%2Fmpromonet%2Fwebrtc-
streamer%2Freleases)
After downloading, you can use the following command to test :
./webrtc-streamer rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov
open localhost:8000 Page visited
Test equipment
If there is no problem , You can use the local device to test , The default address of Hikvision video stream is :
rtsp:// account number : password @IP Address :554/Streaming/Channels/101
Replace the corresponding information for testing .
If it's in windows Next ,webrtc-streamer It also grabs snapshot pages of windows and screens , have access to -q Parameters are filtered , It supports regular expressions . This parameter is not in
help The list is listed in the source code I found .
./webrtc-streamer rtsp:// account number : password @IP Address :554/Streaming/Channels/101 -q (?=rtsp).*
Integrate
You can download the distribution package in html Found in folder index.html To see the sample code , Here's the core code :
<html>
<head>
<script src="libs/adapter.min.js" ></script>
<script src="webrtcstreamer.js" ></script>
<script>
var webRtcServer = null;
window.onload = function() { webRtcServer = new WebRtcStreamer("video",location.protocol+"//"+window.location.hostname+":8000"); webRtcServer.connect("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");}
window.onbeforeunload = function() { webRtcServer.disconnect(); }</script>
</head>
<body>
<video id="video" />
</body>
</html>
Use WebComponent Integrate
<html>
<head>
<script type="module" src="webrtc-streamer-element.js"></script>
</head>
<body>
<webrtc-streamer url="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"></webrtc-streamer>
</body>
</html>
summary
Mainly right webrtc Familiar with , You can (https://links.jianshu.com/go?to=https%3A%2F%2Fwebrtc.org%2Fgetting-
started%2Foverview) Find the guide .
For example, what is TURN server, What is? peer connections You can find it in the guide above .
边栏推荐
- Everything I see is the category of my precise positioning! Open source of a new method for saliency map visualization
- 【机器学习】线性回归预测
- 利用Scanorama高效整合异质单细胞转录组
- 【CVPR 2020】会议版本:A Physics-based Noise Formation Model for Extreme Low-light Raw Denoising
- 使用递归形成多级目录树结构,附带可能是全网最详细注释。
- Dart series: using generators in dart
- 【ICPR 2021】遥感图中的密集小目标检测:Tiny Object Detection in Aerial Images
- What problems need to be solved by MES management system in the era of intelligent manufacturing
- 苹果Iphone14搭载北斗导航系统,北斗VS GPS有哪些优势?
- 想开户炒股,通过网上进行股票开户安全吗?-
猜你喜欢

Cvpr2022 𞓜 thin domain adaptation

【ICPR 2021】遥感图中的密集小目标检测:Tiny Object Detection in Aerial Images

用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧

Common core resource objects of kubernetes

JS input / output statements, variables
![[image detection saliency map] calculation of fish eye saliency map based on MATLAB distortion prompt [including Matlab source code 1903]](/img/36/134c573c2198ca6c88a7c179189f1a.jpg)
[image detection saliency map] calculation of fish eye saliency map based on MATLAB distortion prompt [including Matlab source code 1903]

【机器学习】线性回归预测

Skywalking installation and deployment practice

What should I pay attention to in the interview of artificial intelligence technology?

13 `bs_ duixiang. Tag tag ` get a tag object
随机推荐
Empty encoded password警告原因
【小程序】相对路径和绝对路径的表示符
What problems need to be solved by MES management system in the era of intelligent manufacturing
机器学习中 TP FP TN FN的概念
Handwritten digit recognition using SVM, Bayesian classification, binary tree and CNN
[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.
[CVPR 2022] high resolution small object detection: cascaded sparse query for accelerating high resolution smal object detection
Dart series: using generators in dart
使用worker报错:Uncaught DOMException: Failed to construct ‘Worker’: Script at***
Theoretical analysis of countermeasure training: adaptive step size fast countermeasure training
Real time computing framework: Spark cluster setup and introduction case
利用Scanorama高效整合异质单细胞转录组
[CVPR 2020] conference version: a physics based noise formation model for extreme low light raw denoising
Cvpr2022 𞓜 thin domain adaptation
[applet] when compiling the preview applet, a -80063 error prompt appears
实时计算框架:Flink集群搭建与运行机制
【CVPR 2022】高分辨率小目标检测:Cascaded Sparse Query for Accelerating High-Resolution Smal Object Detection
【CVPR 2020】会议版本:A Physics-based Noise Formation Model for Extreme Low-light Raw Denoising
[applet] indicator of relative path and absolute path
How to write peer-reviewed papers