Mac Webcam Streaming

This page explains how to stream live video from a webcam to ffmpeg using off-the-shelf components. You will need:

  • VLC
  • ffmpeg

Overview

The general idea is:

  • QuickTime Broadcaster captures the video stream and registers itself as an RTSP server at the Darwin Streaming Server.
  • VLC tunes into this streaming server, transcodes, and serves the stream on HTTP.
  • ffmpeg tunes into the HTTP stream.

The reason behind this is that ffmpeg seems unable to tune into the RTSP stream directly or is unable to handle the audio format offered by QuickTime. Using VLC to transcode avoids this problem.

Setup

First, install everything.

Next, start QuickTime Broadcaster, and broadcast using the following settings:

  • Audio: MPEG-4
  • Video: MPEG-4, increase width/height/data rate
  • Network: Automatic announce, using 'mystream' as file

If starting the broadcast produces a 'precondition failed' error, try to announce a different filename.

Then, start VLC, and enter File -> Stream/Transcoding Wizard. Select:

  • 'Stream to network', press Next.
  • Stream: rtsp://127.0.0.1/mystream.sdp, press Next.
  • Streaming method: HTTP, press Next.
  • Transcode Video: MPEG-4, Transcode Audio: MP3, press Next.
  • MPEG TS, press Next.
  • Select 'local playback' if you want, press Next.
  • Press Finish.

Finally, start ffmpeg:

ffmpeg -i http://localhost:8080 foo.avi