Get a live feed of your house wherever you are! All steps here.
Features- Streams to Youtube
- Plug 'n play
- Night vision
- View on any device
- Compact
- Share with people
Before you can make this, create a youtube account (if you don't already have one) and connect your camera to your raspberry pi.
Setting up Youtube StreamTo set up your live stream, go to youtube.com. On the top-right of the page, you should see this:
Click the left-most button. Then click "go live".
Then click "stream now classic".
Continue to "stream now classic".
After clicking the blue button, scroll down to "basic info". Set the privacy to "unlisted".
Unlisted means anyone with the link can view the stream, but it's not public. Beneath that, you should see "enoder setup".
Keep this tab open, as the stream name/key will be important.
Stream to YoutubeFirst, make a file with the name of "stream.sh" in home/pi. Inside the file write this command. Replace "streamkey" with your stream name/key after revealing it.
raspivid --nopreview -o - -t 0 -w 1280 -h 720 -fps 25 -b 4000000 -g 50 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/streamkey
This file be needed for making it run on boot.
This command streams what it receives from the webcam to Youtube using your stream name/key. Here is an explanation of this command from the official Raspberry Pi website:
You may notice --nopreview
is not explained in this website. Without --nopreview
, your entire screen will be filled with a preview of what is being seen by the camera, making it so that you cannot do anything else on your raspberry pi.
If you run this command on terminal, you should see a live stream of your camera going onto Youtube. To view it, click your profile picture on the top-right of your screen. Then click "your channel".
Click on "your videos", and you should see the stream. Click on it to view it.
NOTE: the stream is delayed by about 15 seconds.
Making it Run on BootMaking it run on boot is extremely useful. Now, we must make it so that you can plug it in and your stream automatically starts.
"rc.local" is a file that runs on when you power up your raspberry pi. To edit it, write this command in your terminal:
sudo nano /etc/rc.local
Sudo
may not be needed, but it means do the following as root-user.
Nano
means edit the following script.
/etc
is the folder in which rc.local
is located.
Now, edit the file so it says only this:
#!/bin/sh -e
sleep 15
home/pi/stream.sh &
exit 0
sleep 15
waits for fifteen seconds.
home/pi/stream.sh &
runs this script.
You may not have permission to run stream.sh yet, so type this in another terminal window:
sudo chmod -R 777 home/pi/stream.sh
Now, you can read and write on this file. Now, if your run rc.local, you should get the same result as when your ran the streaming command in your terminal. Run it by rebooting your device, and it should start streaming about fifteen seconds after you get to your desktop. It now streams on boot!
Making a Case/BoxThe goal is to have the box as small as possible. Cut out a little platform that outlines the raspberry pi's edges. Hot glue the raspberry pi to the platform. The height from there should rise a few centimeters over the platform. Cut out holes for the camera ribbon cable, and the microB port for power. That's it!
Thanks for seeing this! Comment any questions.
Comments