Creating time lapse videos with Raspberry Pi camera

The command below shoots series of photos every 2.5 seconds for 1 hour:

raspistill -n -ISO 100 -q 80 -w 1280 -h 720 \
    -o $DIR/img_%05d.jpg -th none -mm matrix -drc low \
    -t $((1*3600*1000)) -tl 2500

Here -t flag sets total shooting duration in milliseconds, while -tl flag sets pause between two shots. Photos are saved under directory configured with $DIR environment variable.

These photos can then be stitched together to a video. On macOS this can be done with QuickTime Player: File → Open Image Sequence.

For scenes like sunrise/sunset, cloud movement, shots made every 1-2.5 seconds targeted to 25-30 FPS videos work well.

The downside of this approach is storage required to keep intermediate frames and time it takes to copy them off Raspberry Pi (over WiFi this can take a while). An alternative way is to shoot directly to video with raspivid command — result will require much less space on Raspberry Pi storage and can be copied much faster. The only disadvantage is that 1 FPS is the slowest value supported.

Record 1280×720 video for 1 hour at 1 FPS:

raspivid -n -b 300000 -ISO 200 -w 1280 -h 720 \
    -o timelapse.h264 -mm matrix -drc low \
    -fps 1 -t $((1*3600*1000))

Bitrate of 300000 is enough for sky scenes at 1280×720, more detailed scenes may require adjustments.

Wrap this H264 video with MP4 container setting target FPS to 30 (install ffmpeg with sudo apt install ffmpeg):

ffmpeg -y -r 30 -i timelapse.h264 -vcodec copy timelapse.mp4

With these settings 1 hour of capturing would result in 2 minutes video.