/ Technical

Streaming Webcam on Raspberry Pi

Messing about with MJPG-streamer, a Raspberry Pi and a PS3 EyeToy C270 camera. See the live feed at darrenwatt.com/cam (if it's running).

Things I've learnt from messing around with mjpeg-streamer####

mjpeg streaming is literally sending a bunch of jpeg images to the browser, which is good because it works natively on a lot of browsers and without rubbish like Java or Flash.

Some webcams support mjpeg streaming, some don't. The PS3 EyeToy (£5 on eBay) camera I started testing with doesn't, so you have to set mjpeg-streamer to YUV mode to get any output. This means more processing on the streaming host, in my case a Raspberry Pi Model B, which pushed it's CPU usage to 100% flat out, lag, dropped frames, heat & general unhappiness.

After replacing it with a Logitech C270 (£20 everywhere) which does support MJPEG the Pi seems a lot happier, less dropped frames, CPU usage ~30%.

# stream.sh #
#!/bin/bash
killall mjpg_streamer
/usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_uvc.so -d /dev/video0 -n -r 960x544 -f 30" -o "/usr/local/lib/output_http.so -p 8080 -w /usr/local/www/cam" &

Then add this to your /etc/rc.local before 'exit 0' to get it running at startup
exec /home/pi/stream.sh

I guess a newer/faster Pi would be able to handle higher res, but for me 960x544 @ 30fps is fine.

Some handy links for getting it working####