However, I want to view this stream in a web browser (Firefox or Chrome) using the HTML5 video tag. Apparently, both Firefox and Chrome's implementation of this tag support the video format Ogg, WebM, and MP4 H.264.

If I'm understanding the raspivid/gstreamer commands correctly, it's streaming and consuming H.264 video? However, when I try to consume this via the tag with:

Is there any way to get a low-latency video stream from the RPi that works with the <video> tag? I've seen some examples of using WebRTC or FFMpeg, but these all have 20-30s of latency and don't work with raspivid.

Edit: I followed these instructions to install UV4L via a custom repo and I managed to get the uv4l server running with:

However, this clearly doesn't use the HTML5 <video> tag. I then tried the WebRTC example page, and this does appear to run in the browser, but it's heavily Javascript based, so I can't tell exactly how it's implemented or if I can reuse it in my own application.

I notice from the w3schools page here that all of the examples include a type definition chosen from 3 container options (type="video/[mp4/ogg/webm]". I'm not sure that gstreamer sends this without prompting, so you're likely to need it in your HTML. This SO thread has some (apparently) functional gstreamer strings that might be worth investigating.
– gooberingFeb 21 '16 at 17:41

You'll have 10-20 seconds lag, but the you get 30fps full HD. Send me a message. HLS/ffmpeg is what you'd use.
– 1''Feb 23 '16 at 6:41

@1'' he said realtime,10-20s is not realtime, hls/ffmpeg is not either. only uv4l is realtime.
– prinxisFeb 26 '16 at 3:32

I think using the Video for Linux 2 (v4l2) API driver (official one from the Raspberry Pi Foundation) to stream data straight from the camera is better than using raspivid. I'm trying a udp stream with cVLC (sudo apt-get install vlc), using memory mapped I/O (mmap) options for v4l2-ctl and I would convert this to a mpeg-dash stream on the Pi to view the video over HTTP in a web browser. This is untested. Also see the related question raspberrypi.stackexchange.com/questions/7446/….
– EdwardNov 18 '17 at 18:41

The best and easiest way to stream to a browser is UV4L with WebRTC (much better than mjpeg). It works "out-of-the-box" with the embedded streaming server. No command sauces are required. It optionally supports audio as well. Audio and/or video can be bidirectional. The streaming server can load customized pages too. With chrome (much better than Firefox) latency can be as low as 150ms with Full HD hardware-encoded h264.

The problem with the UV4l solution is that (a) it is closed source and (b) it will overlay the project url on your videos.
– larsksMar 25 '18 at 4:39

I like webrtc from uv4l for this, but I can't find a simple javascript shim to serve up the video :/ most of the examples are way too complicated and based on assumptions that it is being used for video conferencing.
– tedder42Nov 1 '18 at 19:56