Skip to content

geocolumbus/pi-timelapse-camera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi Time Lapse Camera

This project consists of a README file that explains how to set up a Raspberry Pi 3 with a V2 Camera to take timelapse photos from 1/2 hour before sunrise to 1/2 hour after sunset, and a camera python3 script and some shell scripts.

The photos are taken once every 6 seconds, and stiched together into a H264 encoded movie of about 100-200 MB in size. It takes the Pi about 1.5 hours to compress the images into videos using ffmpeg starting about 9:40 pm at the end of the day.

Sample Video

Columbus Ohio Time Lapse Video

Hardware

Configure the Pi

Basic Configuration Information

This is hardly complete, but it is basic info to get a Raspberry Pi up and running as headless server on a home WIFI network.

Install SSH to the Pi

mkdir ~/.ssh
cd ~/.ssh
chmod 700 ~/.ssh
wget https://dl.dropboxusercontent.com/u/somenumber/authorized_keys  <- stick your key up on Dropbox!
chmod 600 ~/.ssh/authorized_keys
sudo raspi-config   <— turn on the ssh

Install the Camera

The camera can be controlled by running python3 scripts.

sudo apt-get install python3-picamera

Turn the camera on from rasp-config

sudo raspi-config

see Raspberry Pi Basic Camera Recipes for details on how to write python code for the camera.

Install ffmpeg

ffmpeg converts the individual timelapse photos into a compressed, high definition video.

build and install x264

git clone --depth 1 git://git.videolan.org/x264
cd x264
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
make -j 4
sudo make install

build and make ffmpeg

git clone --depth=1 git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg

Note - set architecture to armhf for Pi3 (hardware float) vs. armel for Pi2 (software float).

./configure --arch=armhf --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
make -j 4
sudo make install

see ffmpeg on raspbian / Raspberry Pi for more details on ffmpeg.

To execute ffmpeg, use the makemovie.sh script.

# Takes files from the timelapse/done folder and stiches them into a movie in the movies folder. 
ROOT=/home/pi
FILENAME=`date +%Y-%m-%d`
rm "$ROOT/camera/movies/$FILENAME.mov"
/usr/local/bin/ffmpeg -r 25 -pattern_type glob -i "$ROOT/pi-timelapse-camera/timelapse/done/*.jpg" -c:v libx264 "$ROOT/pi-timelapse-camera/movies/$FILENAME.mov"

Running the Python Scripts

git clone https://github.com/geocolumbus/pi-timelapse-camera.git

cd pi-timelapse-camera

Create these folders:

pi-timelapse-camera
  |-timelapse
  |  |-done
  |-movies

Run the script python3 cam.py and images will start accumulating in the timelapse folder.

The first time you run the python camera script you will get errors about missing dependencies. That's expected - you need to install the dependencies as specified in the error messages, or from this dependencies list in the camera script. See INSTALLING PYTHON PACKAGES for details on how to use apt-get or pip to install Python dependencies.

from time import sleep
from picamera import PiCamera
from time import localtime, strftime
import ephem
from datetime import datetime
from dateutil import tz
import os

A sample crontab is supplied to tie the system together. The python script adds a new image to the timelapse folder every 6 seconds. Every so often, those images are moved to the timelapse/done folder. At 9:40pm, a makemovie.sh script converts the images in the timelapse/done folder into a H264 encoded move in the movies folder.

About

Raspberry Pi timelapse camera files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published