A simple python script for timelapse video recording:
from picamera import PiCamera
from time import sleep
import os
path="/home/pi"
path = os.path.join(path, 'timelapse')
if not os.path.exists(path):
os.mkdir(str(path))
img_count = 0
while True:
with PiCamera() as cam:
cam.capture(os.path.join(path, str(img_count).rjust(10,'0')+".jpg"))
print("writing: " + os.path.join(path, str(img_count).rjust(10,'0')+".jpg"))
img_count+=1
sleep(60*10)
Writes an image taken with the PiCamera module at every ten minutes, incrementing the file name.
- To get the script to start automatically when the pi is powered on, just add the line:
python /home/pi/timelapse.py &
to /etc/rc.local (before exit 0):
- To recover the images, mount the SD card from the raspi and look in
rootfs/home/pi/timelapse/%10d.jpg
- To make a simple video using ffmpeg
ffmpeg -i %10d.jpg -filter deflicker=s=4:m=hm out.mp4
note that the script will overwrite the files and start from 0 every time you plug it in.
Ещё видео!