Last active
June 30, 2018 12:58
-
-
Save davity/72c432d5637793d2a715477fd48febfd to your computer and use it in GitHub Desktop.
Raspberry Pi Timelapse with Cron
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will make 60fps FullHD (1920x1080) timelapses of 1 day into 6 seconds. | |
# 1 photo every 4 min -> 360 photos/day -> 360photos/60fps = 6 seconds | |
# | |
# Weekly videos will have a duration of 42 seconds. | |
# Monthly videos will have a duration of ~3 minutes. | |
# | |
# With this values no one will get bored watching it when you spam it on WhatsApp :) | |
# | |
# If you want slower videos, adjust the value of first cron line "*/4 * * * *". | |
# For example, "*/2 * * * *" will double the duration (1 day = 12 seconds), hence will be half slower. | |
# | |
# Instructions: | |
# 1. Install ffmpeg (sudo aptitude install ffmpeg) | |
# 2. Create folder "/home/pi/lapse/" (mkdir -p /home/pi/lapse/) | |
# 3. Copy this lines into your crontab | |
# Your timelapse machine is ready! | |
# Take the photo! | |
*/4 * * * * raspistill --nopreview --timeout 50 -w 1920 -h 1080 -q 100 -o /home/pi/lapse/lapse_"$(date +'\%Y-\%m-\%d_\%H-\%M-\%S')".jpg | |
# Daily | |
0 1 * * * mkdir daily | |
1 1 * * * mv /home/pi/lapse/* /home/pi/daily/ | |
2 1 * * * mkdir -p /home/pi/video/daily/ | |
3 1 * * * ffmpeg -r 60 -pattern_type glob -i '/home/pi/daily/*.jpg' -s hd1080 -vcodec libx264 /home/pi/video/daily/daily_"$(date +'\%Y-\%m-\%d_\%H-\%M-\%S')".mp4 | |
# Weekly <- Daily | |
0 2 * * 7 mkdir weekly | |
1 2 * * 7 mv /home/pi/daily/* /home/pi/weekly/ | |
2 2 * * 7 mkdir -p /home/pi/video/weekly/ | |
3 2 * * 7 ffmpeg -r 60 -pattern_type glob -i '/home/pi/weekly/*.jpg' -s hd1080 -vcodec libx264 /home/pi/video/weekly/weekly_"$(date +'\%Y-\%m-\%d_\%H-\%M-\%S')".mp4 | |
# Monthly <- Weekly | |
0 3 1 * * mkdir monthly | |
1 3 1 * * mv /home/pi/weekly/* /home/pi/monthly/ | |
2 3 1 * * mkdir -p /home/pi/video/monthly/ | |
3 3 1 * * ffmpeg -r 60 -pattern_type glob -i '/home/pi/monthly/*.jpg' -s hd1080 -vcodec libx264 /home/pi/video/monthly/monthly_"$(date +'\%Y-\%m-\%d_\%H-\%M-\%S')".mp4 | |
# Archive photos first of month | |
0 7 1 * * mkdir archive | |
1 7 1 * * mv /home/pi/monthly/* /home/pi/archive |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great!!!