Posted in Raspberry Pi

Youtube Live streaming using Raspberry Pi

This blog describes how to stream video + audio to Youtube Live events using Raspberry Pi. There are lot of sites online that describe how to Live stream a webcam video to Youtube with Raspberry Pi but no where I found working solution for live streaming both Audio & Video to Youtube. Hence this blog..

Bit of background:

I work for a non-profit organization that needed a free 24/7 webcam streaming. They were using VLC in tandem with Quicktime broadcasting for last 10 yrs that worked great until the recent advent of new HTML5 and Mobile platforms. It became obsolete especially due to its need for Quicktime browser plugin and lack of support for Mobile platforms.

After some research, Youtube Live events came out to be the only free streaming solution. Initially I tried using Adobe Flash Live encoder to live stream to Youtube but its a User-interface driven tool and not a fire-and-forget type solution. This where Raspberry Pi fit the job.

Raspberry Pi 2: a tiny, cheap yet savory unix box


Needed components:

  1. Raspberry Pi 2 or 3
  2. SD card to load Raspbian OS
  3. Camera component
  4. WiFi adapter (only if its Raspberry Pi ver 2. WiFi & Bluetooth are built-in to Raspberry Pi from ver 3+)
  5. USB Audio adapter
  6. USB Micro-phone
  7. Power adapter
  8. Raspberry Pi case (optional)
  9. Keyboard, Mouse, HDMI cable, Monitor.  This is optional and only needed until you setup SSH. Alternatively, you can use this cool PiBakery project to burn SSH and WiFi info directly into your SD card thus avoiding needs for initial peripherals to boot up RPi.

Here is the command that works to stream both Audio and Video:

Key points:

  1. You need to install the ffmpeg onto your RPi in order use above script. I’ve detailed its setup in my blog here.
  2. For some reason, Audio starts falling behind the Video after about 20 mins. To give better user experience, I setup a Cron job to re-start above ffmpeg script code every 20 mins. Since Youtube does DVR of your live streaming, users won’t notice any difference.

Here is its screenshot: