The ultimate solution for playing rtsp video streams on web pages

background

I have reprinted a big guy’s solution of using client ffmpeg + script jsmpeg + server node before. By transcoding rtsp on the server and then using websocket to push it to the front end, this method can realize playing rtsp video stream in h5, but After using it for a few days, I found many problems:

1. There is a serious delay in ffmpeg transcoding, which is about 1s. It is more complicated to use hardware acceleration by optimizing commands. For a novice like me with 0 audio processing experience, the learning cost is too high, so I abandoned the idea of ​​hardware acceleration.

2. ffmpeg transcoding sometimes gets stuck, which is a disaster for us who are engaged in security.

3. The official description of jsmpeg is in English. I am a novice in English and I can’t understand how to play multiple video streams. During the process of exploration, the browser console always reported various exceptions, and Du Niang couldn't find a solution.        

In general, even if I am a good person, I will abandon the solutions that cannot be solved with one click.

plan

Then we have to change a solution, which is basically an advertisement, or it is a lower version browser with plug-ins, or the middleware requires us to pay IQ tax!

No way, I can only go to github to try my luck, I didn't expect to find a treasure, I'm such a clever little ghost.

The nonsense is almost enough, the link

Low-latency solution for webpage playback RTSP video stream RTSP to WebRTC use Pion WebRTC. Contribute to deepch/RTSPtoWebRTC development by creating an account on GitHub. https://github.com/deepch/RTSPtoWebRTC This is a better one I found on github The open source solution is developed using the Go language. If you don’t have a Go language foundation, you can go to the rookie tutorial Go tutorial to learn for a few minutes. After installing the environment, it will be OK. I also learned it on the spot, with the mentality of giving it a try.

Go Language Tutorial | Novice Tutorial

operate

Let's talk about how to play this open source project. In fact, the author of the project has written it better in the readme file. Let me just talk about the problems I encountered.

1. After downloading the zip package of the project, we unzip it, and first modify the rtsp video stream address of the config.json file in the project to our video stream address

2. Then you can use the go run *.go command to run the project. If no error is reported after startup, you can use the browser to open http://127.0.0.1:8083 to view the demo effect of the project

Effect

Latency: <500ms

Sharpness: High

Performance: stable

Generally speaking, this is the most satisfactory solution I have encountered so far. The platform is simple to build and the effect is good. I write this blog post and hope that everyone will not be fooled again.

Guess you like

Origin blog.csdn.net/qq_36694133/article/details/121670963