markszabo / tapo-c200-timelapse

This is my setup to take time-lapse videos from my balcony with a Raspberry Pi using a TP-Link Tapo C200 IP-Camera
91 stars 17 forks source link

Time-lapse with a Raspberry Pi and a TP-Link Tapo C200 IP-Camera

This is my setup to take time-lapse videos from my balcony with a Raspberry Pi using a TP-Link Tapo C200 IP-Camera.

Time-lapse

High level overview

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.

Size requirements (with my setup):

Dependencies

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

Setup

  1. mv timelapseconfig.py_example timelapseconfig.py and update it accordingly
  2. python3 capture.py (VLC) or python3 capture_ffmpeg.py (FFMPEG) to see if it works
  3. Check the images being created
  4. If everything looks good, add it to crontab: crontab -e
*/10 * * * * /usr/bin/python3 /home/pi/timelapse/capture.py >> /tmp/timelapse.log
  1. Wait for a day, check the images
  2. Try the video assembly: python3 makevideo.py
  3. If it looks good, add it to crontab as well: 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.

  1. Wait until next month, check the images
  2. Try the monthly-video assembly: python3 monthlyvideo.py
  3. If it looks good, add it to crontab as well: 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:

TODO and improvements