Skip to content

Streaming live video from a webcam via Deefuzzer

achbed edited this page Jan 30, 2015 · 1 revision

For real time task like live encoding from audio and video sources, I use the GStreamer framework rather than ffmpeg. I use ffmpeg a lot, it's a great tool but really better for post-process and non realtime processes. Even I've invested money some years ago to include the JACK plugin in it, thinking I could use it for live process, I've never manage to get audio and video synchronized and stable enough.

So here is how I start a GStreamer 0.10 pipe taking the webcam with the V4L driver and the audio from the JACK server:

gst-launch v4l2src device=/dev/video0 ! video/x-raw-rgb, width=864, height=480, framerate={30/1}  \
        ! queue ! ffmpegcolorspace \
        ! queue ! vp8enc speed=2 threads=4 quality=10.0 max-latency=25 max-keyframe-distance=30 auto-alt-ref-frames=true ! queue ! muxout. \
        jackaudiosrc connect=2 ! audio/x-raw-float, channels=2 \
        ! queue ! audioconvert ! queue ! vorbisenc quality=0.4 ! queue ! muxout.  \
        webmmux streamable=true name=muxout \
        ! tcpserversink host=127.0.0.1 port=9000 protocol=none blocksize=65536 sync-method=1

Note you'll need to adjust some object names for use with GStreamer 1.x.

At this point, the webm stream is available on the port 9000 of the localhost. You can browse it with Chromium/Chrome at http://localhost:9000

To scale the stream of the net, I use stream-m on a server: https://github.com/yomguy/stream-m

with at least this minimal configuration:

server.port=8080

streams.monitor=true
streams.monitor.password=xxxxxxxx
streams.monitor.limit=100

Then, finally use the deefuzzer in relay mode to relay the local stream to the server. Just adjust those parameters in the YAML config file:

deefuzzer:
  log: /var/log/telecaster/telecaster_webm_monitor.log
  m3u: /var/www/m3u/telecaster_webm_monitor.m3u
  station:
    control: {mode: 0, port: 16002}
    infos: {description: TeleCaster WebM monitor stream, genre: Vocal, name: monitor, short_name: monitor,
      url: 'http://parisson.com.com'}
    jingles: {dir: /path/to/jingles, mode: '0', shuffle: '0'}
    media: {bitrate: '512', dir: /usr/local/share/telecaster/media/webm, format: webm, ogg_quality: '4',
      samplerate: '48000', shuffle: '0', voices: '2'}
    record: {dir: /home/telecaster/trash/webm, mode: 1}
    relay: {author: TeleCaster, mode: '1', url: 'http://127.0.0.1:9000/'}
    rss: {dir: /var/www/rss, enclosure: '0', media_url: 'http://localhost/rss/'}
    server: {host: 127.0.0.1, port: '8080', public: '0', sourcepassword: xxxxxxxx,
      type: stream-m, mountpoint: monitor}
    twitter: {key: 76728330-OjKgbHtn4II86Ad7pNUGEzfNAkGTW5Wvw38qUmLE, mode: '0', secret: 4egZs1dSM37XVY8zXa016Yueku2fleXF2bx8k25V4,
      tags: bla bla}

Adjust the passwords, the hosts, etc to you needs. Note that stream-m need explicit names for each mountpoints (here "monitor").

Et voilà !

ref: https://github.com/yomguy/DeeFuzzer/issues/24