Streaming Your iSight Camera to the Web with the Video Tag

I wanted to do a demonstration of live streaming using the <video/> tag for my talk at the upcoming Open Source Bridge conference; maybe a stream a surprise guest in, do some audience interaction, something fun. I figured the easiest way to test the streaming myself would be to use the webcam in my MacBook Pro’s built-in iSight camera.

I pinged Asa to get details about how he streams Air Mozilla, which brought Icecast into the picture. I found some old posts about using VLC on Linux to capture the external iSight, so tried it… but no dice, the capture module barfed when trying to talk to the camera. VLC ships with a capture module for the iSight, but hasn’t been updated to work with the internal iSight. Bah. VLC also supported transcoding to Ogg Theora, as well as streaming to Icecast servers, so it really seemed like it’d provide just about everything, if it only supported the camera.

I looked up the error I got from VLC, posted on the VLC forums, no answers. So I emailed the author of VLC’s Quicktime module, Pierre d’Herbemont, at the email he left in the source file. After a couple of emails, and less than 24 hours later, he’d checked in a fix. Open source FTW. Thanks Pierre.

The steps to get it working are enumerated below. At some point, the VLC fix will ship, but until then you’ll need to use nightly builds.

Install and configure the Icecast2 server:

  1. Install MacPorts
  2. In the Terminal: sudo port install icecast2. This installs everything into various dirs in /opt/local.
  3. Edit /opt/local/etc/icecast.xml, set user/group it runs as (for logfiles, i set mine to _www, same as Apache), and change the default passwords in the authentication section.
  4. Set permissions on /opt/local/var/log/icecast to be writable by the user you configured Icecast to run as.
  5. In the Terminal, start the server: sudo icecast -c /opt/local/etc/icecast.xml -b
  6. Test your install by checking the server’s status at http://localhost:8000/status.xsl
  7. Watch the log in the Terminal: tail -f opt/local/var/log/icecast/error.log (Useful for confirming VLC access, as well as catching authentication problems)

Start the stream:

  1. Download and install the most recent VLC nightly build
  2. Open the terminal, and execute the command below
  3. Open http://localhost:8000/stream/isight with Firefox 3.5b4 (or newer)

VLC Command (all one line):

/Applications/VLC.app/Contents/MacOS/VLC qtcapture:// –sout=”#transcode{vcodec=theora,vb=256,venc=theora,acodec=vorbis,ab=64,aenc=vorbis}: standard{access=shout,mux=ogg,dst=source:yourpassword@localhost:8000/stream/isight}”

screenshot

It’s still not quite ready for practical use:

  • There’s still some size distortion, maybe I have the aspect ratio wrong or something
  • Still working on sound
  • Lag is pretty bad

11 Comments on “Streaming Your iSight Camera to the Web with the Video Tag”

  1. Dan says:

    Awesome. What version of VLC will ship with the necessary fix?

  2. I was messing with almost the same setup on a Windows laptop a couple of months ago. It worked… but I had the same issues as you: aspect ratio seemed wrong, and a ton of lag.

  3. […] Dietrich Ayala: Streaming Your iSight Camera to the Web with the Video Tag on Planet MozillaTopics: QuickTime, ISight, MacBook Pro, MacBook […]

  4. streaming says:

    whouha, great post, thanks

  5. Boris says:

    Hello,

    I am trying to stream with VLC and ISight.
    However, I always get the following error: [00000395] access_directory access error: standarddst=hackme@localhost:8000/stream/isight”: No such file or directory.
    Which access rights should I put on stream and isight ?
    Is isight a file or a directory ?

    Thanks

    • i haven’t seen that error, sorry 😦

    • Deniz says:

      Hey, I had same problem, try this:

      /Applications/VLC.app/Contents/MacOS/VLC qtcapture:// –sout=’#transcode{vcodec=theora,vb=256,venc=theora,acodec=vorbis,ab=64,aenc=vorbis}:std{access=shout,mux=ogg,dst=source:password@localhost:8000/stream/isight}’

      The bad thing is its working on only firefox. Anyway, thanks for info Dietrich.

  6. Boris says:

    Can you please answer my questions ?
    Thanks.

  7. Saibi Rocker says:

    Hi
    I am using MediaFileSegmenter command to create segments
    I am using this command
    mediafilesegmenter -t 10 /Sites/song.mp3
    On running this command i am getting this
    Processing file /Sites/song.mp3
    Aug 30 2010 23:17:28.783: can’t create byte stream /Sites/song.mp3 2
    Aug 30 2010 23:17:28.784: No valid tracks found
    Aug 30 2010 23:17:28.784: average bit rate is 0 – max file bit rate is 0

    How can i solve it, do you have any idea? I am in hurry and need to do it urgently. Any little help will be appreciated greatly in this regard..


Leave a comment