I would like to display IP cameras streaming in RTSP into a web page.
I've tried many solutions, like using VLC to transcode the stream, but none of them seems to be reliable enough to create a real web service. I'm thinking on using some media server like flussonic or Red5. But I don't know if it will work.
This is why I would like to know what is the best (and the simple) solution to display RTSP streams on a webpage.
As a rule, browsers do not support RTSP, so the video stream is converted for a browser using an intermediate server.
One can't directly play RTSP (Real Time Streaming Protocol) streams on HTML5 webpage since RTSP is not supported by the HTML5 <video> tag. But RTSP HTML5 playback is achievable if you transcode RTSP to HTTP, and you can also implement RTSP live streaming by doing so. Keep reading and I'll show you how.
Direct RTSP streaming is still not supported by browsers, if you have to play an RTSP stream in the browser then you need a proxy server that will convert RTSP to HTTP stream.
...to create a real web service.
I've been looking for an answer for the past two or three days (I need support on as many browsers as possible, and latency as low as possible, so WebRTC was the way to go (is there anything better?)) and I've finally found it.
Check out this repo.
From the repo's readme + the additional steps I had to take (on Ubuntu 18.04) to make this work:
Install go
$ sudo snap install go --classic
Get the code on your local device (Could someone enlighten me on what the export is for?).
$ export GO111MODULE=on
$ go get github.com/deepch/RTSPtoWebRTC
This step didn't work for me, so I just downloaded the code in a .zip file and extracted it in the given directory and proceeded. (What did I miss? The src directory was not there before I made it)
$ cd ~/go/src/github.com/deepch/RTSPtoWebRTC
Run from current directory.
$ go run .
Then I opened the link below a web browser ( I tested on Chrome, iOS Safari, but it also works on Firefox).
http://127.0.0.1:8083
This took me very little time to implement. Big thanks to the guys making this. All the other stuff I've found is either 5-7 years old and not working or non-WebRTC or a marketed paid service asking for unreasonable amounts of money.
I hope I answered your question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With