This is my setup to take time-lapse videos from my balcony with a Raspberry Pi using a TP-Link Tapo C200 IP-Camera.
The TP-Link Tapo C200 provides an rtsp feed for its video. Once a username and password is set in the app, it is available on: rtsp://user:pass@192.168.a.b:554/stream1 (Use VLC to see if it works.)
My Raspberry Pi takes a snapshot from that video feed at a configurable interval. This would be possible with ffmpeg
, however I found that due to rtsp using UDP by default, the end result was often corrupted. Thus my script uses the vlc library for python, which starts VLC in the background, waits for 10 seconds for the stream to get stable and then starts capturing snapshots. The script only runs for a short period of time (e.g. 10 minutes), and then it is restarted by cron to limit the issues around the camera dropping connectivity or rebooting.
Pictures are collected to a separate folder per day. After midnight an other script is run to assemble the daily timelapse from yesterday's pictures, and then delete most of the pictures (all but every 10th in my setup, but the rate is configurable). This is to save space, but still keep the option to do multi-day time-lapses (e.g. pictures of 2pm every day for a year).
In my setup I take a picture every minute, so that's 1440 pictures a day. With 24 fps it results in a 1 minute long video.
Use with VLC :
sudo apt install libvlc-dev
sudo pip3 install python-vlc
Use with FFMPEG :
Installing ffmpeg-python The latest version of ffmpeg-python can be acquired via a typical pip install:
pip install ffmpeg-python
mv timelapseconfig.py_example timelapseconfig.py
and update it accordinglypython3 capture.py
(VLC) or python3 capture_ffmpeg.py
(FFMPEG) to see if it workscrontab -e
*/10 * * * * /usr/bin/python3 /home/pi/timelapse/capture.py >> /tmp/timelapse.log
python3 makevideo.py
crontab -e
5 1 * * * /usr/bin/python3 /home/pi/timelapse/makevideo.py >> /tmp/timelapse_makevideo.log
This will run it at 1:05 am every night.
python3 monthlyvideo.py
crontab -e
5 4 1 * * /usr/bin/python3 /home/pi/timelapse/monthlyvideo.py >> /tmp/timelapse_monthlyvideo.log
This will run it at 4:05 am first day of every month and create 2 videos: