A puppy is responsible for writing this tutorial!

I reached a new stage in my personal life: I’ve got a puppy! A miniature Dachshund to be more specific called Joey. Btw, I just call him Little Monster.
At the first and almost the second month we tried to leave him alone just for a few hours and we started to extend this period. Now he is 4 months old and we can leave him alone for more than 8 hours. But of course we try our best to spend as much time at home with him as we can. So at an average he stays home alone for 6 hours per day.

Because of this I always wanted to watch him while I am away. I already had a Raspberry Pi 3 and a webcam so I was like why not? 😀 And it turned out to be a success because (as I didn’t know) Youtube keeps all my live streams, so I can watch every day and also it has a lot of streaming options. I use the unlisted video option, so I can share the stream with anyone I’d like but “unauthorized” people can’t see it.

Let’s get into the building

As the title and the introduction says what you need is a Raspberry Pi and a Webcamera.

After that you only need to install Docker and docker-compose to your RPI which  is pretty easy fortunately.

curl -sSL https://get.docker.com | sh
sudo pip install docker-compose

That’s it.

After these line you just have to clone my repo from Github:

https://github.com/gaborvecsei/RaspberryPi-Youtube-Live-Stream

Inside the repo’s folder you can find a Dockerfile, docker-compose.yml and a code folder which contains the necessary bash script file which actually starts the streaming.

If you type sudo docker-compose up than the image will be built from the Dockerfile and after that it starts the streaming to YouTube. In the docker-compose.yml file I added the volumes option so the code folder is responsible for the container’s persistent memory. This means you can edit the files inside that folder in your host machine and the container will be able to “see” the changes.

A few things you have to edit in the docker-compose.yml before you docker-compose up:

  • youtube_live_key: This needs to be your own YouTube live streaming key which you can get from https://www.youtube.com/live_dashboard
  • devices: This is the mapping where we define which video device will be in use. By default it’s video0 but for example if you have more than one webcamera attached than maybe you’d like to stream from device video1.

Start it!

sudo docker-compose up

First it builds the image (which can take a while) and than the streaming starts. Just go to your YouTube Live Dashboard and see it for yourself. 🙂

Advertisements