Lakecam is Raspberry Pi controlled webcam that posts to Instagram and streams to YouTube!
Social media is hard. The algorithem expects consistant uploads with unique content, and I just don’t have the time. So I built Lakecam - a Raspberry Pi controlled webcam that posts to Instagram and streams to YouTube. It was developed for "Quaboag Lakecam Project" but could be useful for other applications too! Here's what it does:
- Reboots every day at noon
- Waits for network
- Takes photo
- Generate's caption
- Posts to Instagram
- Starts streaming to rtmp (ie. youtube, twitch, whatever)
- Keeps streaming until next day at noon, then reboots.
- Repeat...
- Raspberry Pi Zero W (Use a case with plenty of mounting options)
- 32GB SD Card (With raspbian installed, NOOBS or equivelant)
- Logitech C920 Webcam (Any usb webcam or picam will work)
- Micro USB to Type-A cable (To connect webcam to pi)
- USB Power adapter (Use a good 2A charger)
Install raspbian from NOOBS or equivelant. Edit /etc/wpa_supplicant/wpa_supplicant.conf
with set ssid and password of any future wifi connections.
network={
ssid="access-point-name"
psk="password"
}
Install required software.
- python - Programming language
- weather-util - fetch weather reports
- fswebcam - take webcam photos
- imagemagick - crop photos for instagram
- instapy-cli - post photos to instagram
- ffmpeg - stream webcam feed to rtmp
$ sudo apt install weather-util fswebcam imagemagick ffmpeg
$ python3 -m pip install instapy-cli
Build audio.mp3
with 24+hrs of music. Use the royalty-free stuff from the Free Music Archive. I used a bulk download browser extension to download 500+ tracks and combined them with and Audacity. End product was a single 2.4GB mp3 file with 31hrs of classical music.
Move included scripts and audio.mp3
to /home/pi
. Should look like this:
/home/pi/
├── main.sh
├── 1-wait-for-network.sh
├── 2-take-daily-photo.sh
├── 3-generate-caption-weather.py
├── 4-post-to-instagram.py
├── 5-stream-to-youtube.sh
└── audio.mp3
Edit 4-post-to-instagram.py
with instagram account credentials.
Edit 5-stream-to-livestream.sh
with rtmp stream address + key.
Edit crontab -e
to reboot every day at noon and run main.sh
on reboot. Your crontab -e
should look like this:
00 12 * * * reboot
@reboot sh /home/pi/main.sh
Lastly, to wrap things up.
Travel to a scenic location. Connect camera. Mount equipment. Frame shot. Connect to power...and let it run :)