Snippets

Oskar Nadolny Raspberry Pi - timelapse script

Created by Oskar Nadolny last modified
from datetime import datetime, time
import os
import time as timer

picNumber = 0

while True:
    if time(5,00) <= datetime.now().time() <= time(19,00):
    	picNumber += 1
    	command = "raspistill -w 1920 -h 1080 -mm matrix -o cam"+str(picNumber)+".jpg"
    	os.system(command)
    elif time(1,00) <= datetime.now().time() <= time(1,02):
    	command = "avconv -r 24 -i cam%01d.jpg -r 24 -vcodec libx264 timelapse-"+str(datetime.now().day)+"-"+str(datetime.now().month)+".mp4"
    	os.system(command)
    	command = "rm -rf *.jpg"
    	os.system(command)
    	picNumber = 0
    timer.sleep(55) #Remember that taking photo takes 5 seconds

#Install this to use avconv: sudo apt install libav-tools
#To run this script type: python make-timelapse.py
#If you want run it in background, type: python make-timelapse.py &

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.