This is a 3 minute time lapse from 2 September 2018 to 9 March 2019. You will probably see minimal changes, but when the snow comes and melts away, its kinda cool. I also like watching the tree sag under the weight of the snow, then recover. Deer wandering around is also fun, but they go quickly. Fall came late this year and the colors start around November (there is a time stamp on the bottom right) but a storm came through and knocked it all off.
One photo is captured by a desktop web cam that I have mounted outside the cabin, on a Raspberry Pi. Power goes from the lead acid batteries, to a car power plug style converter which moves the voltage from 12v to 5v. I wrote a small script for the raspberry pi to take a photo every twenty minutes during daylight. One of the technical issues I had was the webcam was way to bright and overexposed. Simple fix for that was to keep the webcam on for a while, then choose the 120th frame. At that point, the camera should have exposed correctly, then same that frame to disk.
Each day there are 24 frames captured each day. That works out to about 1 second of video = 1 Day. I am happy with the original video quality, but the compression that YouTube is using is killing the quality even under HD. No Audio. For this project, there are 4284 photos written to disk. Technically, there should be more but….
I had to toss out a significant number of black frames, and it took me a while to figure out why. I have a significant issue with clock drift on the raspberry pi! Most of the time you would never notice this, because the clock auto synchronizes with a server. But without the internet, the clock drifts. It seems to have drifted really badly in the winter getting off by a number of hours, likely due to the cold.
UPDATE: March 24 2019
Here is the code to make this work. It is an extremely simple set of steps. Create a new text file, and copy the contents of the below script into the file. I saved mine as /home/pi/timelapse/timelapse.sh
#!/bin/bash # Timelapse controller for USB webcam # On your raspberry pi, run "sudo apt-get install fswebcam" # This script anticipates being ran as a cron job (see cron instructions) #Setting the location of where we want to store our collected frames. DIR=/home/pi/timelapse/frames #filename will be the date and time of the file in the format of #YYYYMMDDHHMM.jpg; echo of filename is not required but helpful for testing filename=$(printf "$( date +%Y%m%d%H%M).jpg") echo $filename #Capture image # To help the webcam achieve a better exposure, we are collecting 120 frames. # During the collection of the frames, the webcam will adjust the lighting. # After the 120 frames, it will finally capture an image at 1280x720, quality of # 95 out of 100 (to help save space), and place it in our directory we stored # earlier, with the filename we declared earlier based on the date. #The date and time is automatically in imprinted into the image, but if this is #not wanted add the flag "--no-banner" fswebcam -F 120 -r 1280x720 --jpeg 95 --save $DIR/$filename
Next, make the script executable. Use chmod to do this.
chmod +x /home/pi/timelapse/timelapse.sh
Now add the script to your cron settings. I had mine only take a picture ever 20 minutes between 9 am and 4 pm. Three pictures an hour, for eight hours makes for 24 frames per day. That works out to 1 second of video at 24 frames per second. I also only had it capture frames during the middle of the day to avoid long shadows, and empty dark frames. To edit your crontab, type this.
Here is what my crontab looked like when I was done. Skip to the bottom to see my addition to the stock file.
# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command */20 9-16 * * * /home/pi/timelapse/timelapse.sh
Save the edits in the cron editor. Then I recommend rebooting the raspberry pi. Come back 24 hours later, and check your frames folder and you should have 24 pictures!
To compile your pictures into a youtube video, add FFmpeg to your system
sudo apt-get install ffmpeg
Once that is complete, run this command from the directory where your frames are located.
ffmpeg -r 24 -pattern_type glob -i '*.jpg' -c:v libx264 -preset slow -profile:v high -crf 18 -pix_fmt yuv420p -movflags +faststart -g 48 -r 24 /home/pi/timelapseoutput.mp4
This is an extremely confusing command. If you have no idea how to run FFmpeg, I recommend using this command and only adjusting where you store your outputted video, but basically you are asking for:
- 24 frames
- Importing all files with an extension of jpg (aka, your webcam frames)
- Using libx264 (which makes youtube happy)
- Using the slow preset to preserve quality
- Requesting high quality
- Using YUV planar color space with 4:2:0 (which works well with H.264)
- Putting in a flag that identifies this file as a movie file
- Use a “group of photo” option of two times the framerate (24), so 48.
- And I stuck the file in /home/pi/timelapseoutput.mp4 but you can change that
Depending on the number of frames you have, this can take a significant amount of time as computational power on the raspberry pi is, eh, limited. Each frame can take 1.5 seconds (or slower), so for 4,000 frames, you can expect it to take 1 hour and 40 minutes.