Sidebar

Streaming from a webcam

Yesterday, I took receipt of a nice new Dell Mini 10v (review to come after I’ve been using it for a bit). This has a built in webcam and microphone, so of course my first thought was to stream this over the web ;). Luckily, this is pretty easy with a bit of vlc magic.

On the freshly installed UNR Karmic system (Dellbuntu did not even get booted), the camera shows up as /dev/video0, so the command line to stream this on localhost is:


cvlc v4l2:///dev/video0 --sout '#transcode{vcodec=theora}:standard{access=http,mux=ogg,dst=localhost:8080}'

“cvlc” to avoid launching a GUI, “v4l2” to select a Video for Linux 2 input and the rest to output the stream in Ogg Theora on localhost port 8080.
Now this is only half the battle, as only I can watch my antics. The interesting bit is making it available to the rest of the world. This is easy enough with a bit of reverse SSH tunnelling.

ssh -f vps -R 8080:127.0.0.1:8080 -N

”-f” sends ssh into the background, ”-R 8080:127.0.0.1:8080” means that requests on vps’s port 8080 get transparently forwarded to 127.0.0.1:8080 (the port that vlc is streaming to) and ”-N” tells ssh that we don’t want a command to be run on the remote host. All this requires is a server set up with “GatewayPorts” set to yes.

So now, if you want to watch me live, all you have to do is point vlc at http://joshh.co.uk:8080 et voila! (if it’s on).

Show/hide comment form