For a long time you've been able to stream camera video to a browser, but this has almost always involved using inefficient JPEG video or a plugin capable of actual video decoding.
But last week I discovered that right out of the box, VLC media player can produce and serve an HTML5-compatible video stream.
This works by having VLC transcode the video to a format the browser understands. The transcoding has to happen in real time, so a fast computer is needed.
Step 1
Run VLC with the following command. Modify the RTSP path as needed to point at one of your own cameras:
A VLC window should appear and the playback clock should begin incrementing, but no video will be shown since the command specifies the only output is http.
Step 2
Now you need a web page with an html5 video element on it. Just create an empty text file, paste the following line in it, and name the file video.html
Open this html page with a browser. It should immediately load the live video stream. No browser plugins required.
Some notes:
But last week I discovered that right out of the box, VLC media player can produce and serve an HTML5-compatible video stream.
This works by having VLC transcode the video to a format the browser understands. The transcoding has to happen in real time, so a fast computer is needed.
Step 1
Run VLC with the following command. Modify the RTSP path as needed to point at one of your own cameras:
Code:
vlc.exe rtsp://192.168.0.53/ :network-caching=1000 :sout=#transcode{vcodec=theo,vb=1600,scale=1,acodec=none}:http{mux=ogg,dst=:8181/stream} :no-sout-rtp-sap :no-sout-standard-sap :sout-keep
A VLC window should appear and the playback clock should begin incrementing, but no video will be shown since the command specifies the only output is http.
Step 2
Now you need a web page with an html5 video element on it. Just create an empty text file, paste the following line in it, and name the file video.html
HTML:
<video id="video" src="http://localhost:8181/stream" type="video/ogg; codecs=theora" autoplay="autoplay"/>
Open this html page with a browser. It should immediately load the live video stream. No browser plugins required.
Some notes:
- This method works by transcoding the video with the open/free "Theora" codec, wrapping it in the "ogg" container type. This transcoding is rather CPU intensive for high resolution video, but it is necessary for browser compatibility.
- I only got this working in Chrome and Firefox. Internet Explorer does not support Theora video natively. Some mobile browsers don't support it either.
- In theory most browsers should work with H.264 video in the MP4 container. In fact, in theory, this is the most compatible format around. But I was not able to make this work no matter what I tried.
- You can tweak a lot of things in the command that runs VLC. For example if you change network-caching to a lower number, you get less video latency. But if you set it too low it may not work at all, or may cause problems if your network becomes congested. The vb=1600 argument specifies the bit rate (you can put whatever you like in there, too). You can even change the scale of the video or add width and height arguments to tweak the resolution. You can also change the output destination 8181/stream) to change how VLC will listen for connections.