4 ms·
Motion JPEG is arguably better suited to the task as the browser knows not to cache the previous frames by rule. It's actually designed for this exact purpose.
by donatj 11y ago
Motion JPEG is arguably better suited to the task as the browser knows not to cache the previous frames by rule. It's actually designed for this exact purpose.
I made a little example project a few years back. The format is dead simple, keep the connection open, flush multiple JPEGS separated by a header. It's used pretty often by cheap security cameras and is supported by most browsers. It just seems to be not widely known about.
https://github.com/donatj/mjpeg-php https://github.com/donatj/mjpeg-php
- nacs 11y agoI've found MJPEG to be more bandwidth intensive, especially as the resolution increases however, since its flushing the full frame every time (whereas with GIF you could send just the differences between frames).
- donatj 11y agoWould depend on what you're sending. If you take make good advantage of gif interframe transparency and are just sending small updates the result could be very small. That still leaves the problem unless I'm mistaken of the browser hanging on to the old gif frames.
- dag11 11y agoI had a lot of fun making a little real-time visitor counter using Motion JPEG a few years ago! I was quite proud of that :) The demo is still live: http://drewgottlieb.net/2012/07/29/real-time-user-count.html http://drewgottlieb.net/2012/07/29/real-time-user-count.html