当前位置:网站首页>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 .
边栏推荐
- GNN upper edge distributor! Instead of trying to refine pills, you might as well give your GNN some tricks
- JS language precision problem
- Pad User Guide
- Installation and use of winscp and putty
- version `ZLIB_ 1.2.9‘ not found (required by /lib64/libpng16.so.16)
- Application configuration management, basic principle analysis
- version `ZLIB_1.2.9‘ not found (required by /lib64/libpng16.so.16)
- The industrial Internet era will be realized by products, technologies and models derived from the industry itself
- js输入输出语句,变量
- Grab startup logcat
猜你喜欢

ARM学习(7) symbol 符号表以及调试

Open source model library of flying propeller industry: accelerating the development and application of enterprise AI tasks
![[CVPR 2022] high resolution small object detection: cascaded sparse query for accelerating high resolution smal object detection](/img/79/7dfc30565ddee0769ef5f1bc239b5d.png)
[CVPR 2022] high resolution small object detection: cascaded sparse query for accelerating high resolution smal object detection

使用递归形成多级目录树结构,附带可能是全网最详细注释。

ShardingSphere-proxy-5.0.0容量范围分片的实现(五)

The first open-source MySQL HTAP database in China will be released soon, and the three highlights will be informed in advance that shiatomics technology will launch heavily

An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!

牛学长周年庆活动:软件大促限时抢,注册码免费送!

数据管理:业务数据清洗,落地实现方案

ICML'22 | ProGCL: 重新思考图对比学习中的难样本挖掘
随机推荐
Vs2022 save formatting plug-in
LSF opens job idle information to view the CPU time/elapse time usage of the job
Pure JS implementation determines whether the IP is pinged
CVPR2022 | 可精简域适应
使用递归形成多级目录树结构,附带可能是全网最详细注释。
【Flutter】如何使用Flutter包和插件
What do NLP engineers do? What is the work content?
Cvpr2022 𞓜 thin domain adaptation
Handwritten digit recognition using SVM, Bayesian classification, binary tree and CNN
逻辑的定义
SQL database: summary of knowledge points, no suspension at the end of the period
version `ZLIB_1.2.9‘ not found (required by /lib64/libpng16.so.16)
What are the two types of digital factories
An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!
GNN upper edge distributor! Instead of trying to refine pills, you might as well give your GNN some tricks
CVPR2022 | 可精简域适应
Empty encoded password警告原因
[technique of planting grass] spit blood and clean up, and take you to collect goose feathers in a fancy way! Do not spread!!!
Perhaps the greatest romance of programmers is to commemorate their dead mother with a software
Mip-NeRF:抗混叠的多尺度神经辐射场ICCV2021