Automated Time-Lapse Generator – A Raspberry Pi Project
Making time-lapses takes time. And computers have patience. I know, I agree, time lapses should definitely be automated and taken based on information available online. Yes. Yes, I know, it’s way more convenient than leaving a phone somewhere and hoping that the app won’t die (come on apps you can do better than dying after filming for an hour).
One Raspberry Pi, a Camera, and an internet connection later, we have a thing that works and does just that!
Okay enough with the nonsense, let’s dive into the device itself and the way it works! Overall, the flow is pretty simple, and modeled as a state machine.
In some more detail:
- Initialization: set up the variables and objects needed to interface with the camera module
- Getting Sunrise Time – sends HTTP requests to an API that serves information about, among other things, sunrise times (found at https://api.sunrise-sunset.org/json?lat=42.3601&lng=-71.0589 , for information about the Boston area).
- Wait for start- utilize the Raspberry Pi’s time module to keep track of the, well, time. Will stay in this state until the hour is 30 minutes prior to the sunrise time.
- Capture – a 10 seconds time-lapse is made by capturing 300 images over two hours. The timing and variables can be set differently, but that’s how they were set for the example in the video. (To be later run as a video with 30 fps.)
- Share – email out the video created from the stitched images.
That’s great, things are working! Honestly, this is pretty cool 🙂 Though in today’s reality, a product is not complete until it bombards its users with a constant flow of information. It is expected from any app, so I expect the same from my own creations.
Therefore, to know the state of the program in real time, updates are being sent out to a dedicated server-side script every minute. Information about the current state, the projected time of the beginning of filming, and when applicable also the progress of the filming can be found there. The updates can be accessed from a web browser, and look like so:
Despite the fact that the current implementation of the update-provider-script-website-thing serves a fair amount of information, the primary reason for its existence is to inform the user that the device is still alive. It could be unfortunate to wait a while for a time-lapse to be made when in reality the program stopped for some reason. As a note, I should add a functionality that pipes exceptions to the server and presents them on the web if they are raised. That could save time and tears when debugging. A big advantage of being able to get online updates using a web browser is that they are available worldwide! Tuning in to that website over Winter break, when I was in the other side of the globe was very nice.
Overall, this was a fun little project to make! Owing to the craziness of the past semester, I am happy to have survived and also got to make something 🙂
In the future, I will no longer film time-lapses out of library windows, but will be able to take pre-timed videos from any place equipped with an internet connection! I might try to leave the box around campus some day with the hope that it will stay there the following day , and maybe even produce a cool video 🙂