This codebase is all the code & infrastructure needed to turn a Raspberry Pi into a timelapse camera.
- Setup the Pi
- Connect the camera to the Pi
- Setup the camera (Interface -> Enable Legacy Camera -> Do not restart.)
sudo raspi-config
- Run our download script to skip some file renaming and moving (otherwise, do it manually by following the script line by line)
curl -fsSL https://raw.githubusercontent.com/dhs-envirotech/timelapse/main/download.sh | sudo bash
- Run the setup script. It will install all the packages needed, and write (or overwrite) a new crontab at
/etc/cron.d/timelapse
. Takes effect immediately.
sudo python3 timelapse.py setup
- Restart the computer
sudo reboot now
build.sh
takes thesrc
directory and compresses it forscp
- To force a sync in the browser time, open the JS console in the web page and run
syncServerTime()
- A preview image cannot be taken in the first minutes of the hour to keep the camera free for the cron scripts.
To change the frame rate of the video, there are 2 things to consider.
- The
frame_rate
variable invideo.py
controls the actual framerate - To supply the right amount of frames, the cron jobs in
setup-timelapse.py
need to be modified.
View the cron config in timelapse.py
If the frame rate represents the # of frames present at video compile time, there will a smooth, equal # of frames per second.
Frontend
: This project uses Flask to serve and a simple single page website (styled with PicoCSS).Bash
: Although the previous version of this project uses Perl as the low-level Linux "commander", I am sticking with Bash. A cron job triggerspicture.sh
to take a picture withraspistill
. A twist I added, however, is to leverage ImageMagick to add the timestamp of the image onto the image itself which makes testing and viewing much more descriptive. For making the videos, another cron job triggersvideo.sh
which first, makes a timelapse from the pictures found in the pictures directory. It deletes these pictures as they are no longer needed and then checks for a previous timelapse to combine with the new one. Finally, the video is renamed totimelapse.mp4
which can be viewed from the web server. The video mainpulating software is [ffmpeg]
If anything is missing here that is in the codebase, please open an issue