Use your Raspberry Pi to stream your IP camera to You Tube

7 minutes reading time (1460 words)
Looking to stream an IP camera to YouTube via a Raspberry Pi. Yes it can be done, and what's more it's reasonably easy to do. The use case for this article is based on setting up a feed for a weather camera, but you can follow the same process if you have another use case in mind.
I've been running the Weather Display software for logging all my weather data for years. I've always felt though that leaving a PC or laptop (I've tried both) on 24 hours/7 days a week just to collect and store weather data was a bit excessive. So the challenge was set - could I run and collect all the data I collected on my PC on a low power device like the Raspberry Pi?
 
You can read about my efforts to get the weather data collection onto the Raspberry Pi in a seperate post. However once I'd done that, I needed to move the webcam capture functionality.
 

What you will need

So I've started with a Raspberry Pi 4 with 4Gb memory, and my IP webcam being a Reolink RLC-511. The Reolink camera has a URL that I can access to get a RTSP (Real Time Stream Protocol) feed from. You might find your camera provides an RTMP feed. I'd recommend using the RTSP one if you can. You can read a bit about the differences here
 
So why not just share the URL to the camera on my website? Well I'm not that keen to give open access to anyone on the internet to my Web camera, so I needed something to sit between the camera, and where I was going to put the feed, in this case YouTube.
 
 

Getting Started

To kick things off you are going to set your camera up. The Reolink camera I used is easy to set up. It is a PoE camera so it's powered via the ethernet network cable that goes to it. I also plugged the other connection to a PoE enabled switch, which was then connected to my main router in the house. This injects the power into the network cable that the camera needs to operate. Reolink do provide self powered cameras, and even solar powered cameras, so choose an IP camera that suits your needs.
 
 

Setting up the software

My software of choice to take the feed from the Raspberry Pi was OBS Studio. I'd looked at a number of alternative options and most were driven from the command line, which I didn't mind too much but if I could find a UI option it seemed easier. Many of the command line options I looked at involved installing ffmpeg with a huge amount of config options. OBS Studio seemed simple enough to use however it was a PC based software - the exact thing I was trying to move away from.
 
Luckily though there is a way to load OBS Studio onto the Pi, and it turned out to be pretty easy, via Pi-Apps. Pi-Apps is a simple way of installing all sorts of software onto your Pi, one of which happens to be OBS Studio. The application "Pi-Apps" should already be available if you are using a standard Raspberry Pi build, otherwise you can run this from the command line to get it
 
sudo apt-get update && sudo apt-get install pistore
 
Once you have Pi-Apps, you can run this by going to accessories under the Pi menu, and clicking on Pi-Apps. You will eventually see a list of folders:
Pi Apps1
 Click on the Multimedia folder and then click on OBS Studio. Then go make yourself a coffee while it installs. Eventually you will end up with an OBS Studio application link to launch the program from, under the Sound and Video section of the Pi main menu! Clicking on that will bring up OBS Studio.

 

Setting up the YouTube side

We're going to start with setting up the YouTube side. If you have streamed live to YouTube before then you can get started immediately. If not you will need to have a verified account, and this process takes 24 hours. YouTube describes the streaming process here
 
Once you are all set up, go to your YouTube account. sign in. and click on the "Create" button (4th icon in from the top right), then click on "Go Live."

A screen will pop up - the key info we want at the moment is shown in the bottom left corner:

YTSettings 1

 

Reveal the stream key, and copy it. Paste it somewhere as you will need it later. Give your stream a name and any other details required by YouTube.

 

Setting up the OBS Studio side

Once you have opened OBS Studio, you will see the main OBS Studio screen. The top half will be blank, and the bottom half will look something like this:

OBS Studio1 

 For the basic setup there's only two places you need to worry about - the sources area and the controls area. For my use case I don't collect sound off the camera. First start with the sources area, in between the Scenes and the Audio Mixer panels.

Click on the plus icon and select "Media Source"out of the picklist that appears. Once the configuration box for the new media source comes up, untick the local file box. You should see something like this screen:

OBS Studio2

Paste the rtsp:// url into the Input field. For a Reolink camera there are instructions on the Reolink website to help you work out what this is. If you can't find a direct RTSP:// URL feed for your camera then you may have luck specifying it as rtsp://<ipaddress of camera>>/1 eg rtsp://192.168.0.16/1 where 192.168.0.16 is the IP address of your camera.

It is worth noting at this point that the IP address for your camera must be fixed. Obviously if this changes, any settings you put into OBS Studio won't then work, and will need updating. Normally you can allocate a fixed IP address on your router to your camera - you should see your router instruction manual if you need more information on how to do that.

You don't need to fill out the input format, and the default settings for network buffering and reconnect delay are fine, although you can fine tune them later if you wish. If you scroll down you will see some other settings, but again the defaults are fine. Click on OK to save everything. If you have done everything right, then the image from your webcam should appear where the blank space was before.

Now to set up the Controls section. In OBS Studio, click on the settings button on the lower right hand side. You will see the following screen 

OBS Studio3

Click on Stream and paste in the stream key you got from YouTube, then click on OK. THere are a number of settings in this area you can play with. For example I've set the following details in the output screenOBS Studio4

 

And the following settings in the Video screen

OBS Studio5

 

After a bit of experimentation, this gives a stream that's the right size for my purpose, and minimises CPU usage. If you leave the settings as default the CPU may run hot on your Raspberry Pi. If you wanted to run the stream permanently you might want to consider purchasing a fan for the Raspberry Pi case.

Congratulations you now have your webcam streaming to your Raspberry Pi! 

  

Starting and viewing the stream

 
 With all that work done you are now ready to start your stream.
1: In OBS Studio, click on "Start Streaming" in the Control section
2: On YouTube Click "Create" and then "Go Live"
3: Wait around 30 seconds and your stream should then go live. You can find it on you channel content under the live tab.
 
YTSettings 2
 
Don't forget that if your stream stops for whatever reason, you need to restart it again in both OBS Studio and YouTube. This will create a new file in your YouTube channel content.
 
That's it. You are now streaming your webcam live to YouTube using a Raspberry Pi. Congratulations!
 

Supporting us and feedback

If you think this article was helpful, there are a number of ways you can thank us. Feel free to add a comment and say thanks in the comments section below. Also you are welcome to register on the site. The more members we have the more it encourages us to write these types of articles. Alternatively if you are into all that social media stuff, feel free to share the article using the buttons below, and tell others about the site. Thanks!!

Font size: +

Related Posts