How To Create a Raspberry Pi Time-Lapse Video or GIF

One frame at a time.
Ash Ash (362)
10 minutes

Time-lapse videos are really easy to create with a Raspberry Pi. Raspberry Pi OS has almost everything we need to get the job done. All you need for this project is a Raspberry Pi, camera, and a subject to capture.

What is time-lapse?

Time-lapse refers to the process of capturing still images of a subject over a long period of time. By combining the images together, a video can be produced. Time-lapse videos can be used for monitoring plant growth, watching the seasons change, or even as security footage with low storage capacity.

Here's a sunset time-lapse recorded on the Raspberry Pi. This was created by capturing one image every 10 minutes.

Raspberry Pi 3 B+Raspberry Pi 3 B+ ×1
Raspberry Pi CameraRaspberry Pi Camera ×1

Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

Raspberry Pi OS

This project starts with an up-to-date installation of Raspberry Pi OS (formerly Raspbian). The code we're using to initiate the time-lapse runs in a terminal window. You can access this using the desktop or remotely with SSH.

If you're not sure where to get started, check out our guide on how to install or update Raspberry Pi OS—the latest OS.

Raspberry Pi OS Enable SSH

If you're using a monitor and keyboard for this project, connect them now.

Enable SSH

If you're using a monitor, open the main menu from the taskbar and go to Preferences > Raspberry Pi Configuration. Under the Interfaces tab, enable SSH. If you're using a headless setup, visit our guide on how to enable ssh without a screen.

Connect to the internet

If you plan to access the Pi remotely, you'll need to connect to the internet. Plug in an ethernet cable if your project involves a wired connection. Wireless users can connect using the wireless icon from the taskbar in Raspberry Pi OS. If you're using Wi-Fi on a headless setup, check out our guide on how to set up Wi-Fi on a Raspberry Pi without a monitor.

Log in to the Pi

Log in to the Raspberry Pi using a terminal window.

Mac users can use Terminal. We recommend Putty for Windows users. Connect to the IP address assigned to the Raspberry Pi and log in using your Pi credentials. Visit our guide on how to log in to a Raspberry Pi via SSH for more details on this process.

Raspberry Pi OS Enable Camera

The Raspberry Pi is somewhat limited in its selection of supported cameras. Most compatible webcams require a powered USB hub. In this guide, I'll be using a camera designed specifically for the Pi. The Raspberry Pi has a specific port designated for the camera module. Turn off the Pi and plug the ribbon cable into the camera slot on the Pi. Visit our guide on how to connect a camera to the Raspberry Pi for more details on this process.

Enable the camera in Raspberry Pi OS

If you're using a monitor, open the main menu from the taskbar and go to Preferences > Raspberry Pi Configuration. Under the Interfaces tab, enable the camera.

Headless users enter sudo raspi-config. Under Interfacing Options, enable the camera. You will be prompted to restart the Raspberry Pi.

Time-lapse videos are created with individual stills. To capture our time-lapse frames, we'll be using the raspistill tool. This is built into Raspberry Pi OS and doesn't require a special download. The following is an example of how to capture time-lapse images.

raspistill -t 10000 -tl 2000 -o pic%04d.jpg

10000 refers to the duration of the time-lapse capture, in this case, 10 seconds. 2000 determines how long the Pi will wait between each picture. In the example code above, the Pi will capture an image every two seconds for ten seconds.

The images will be saved as .jpg files. In the example, each picture will be named "Pic" with a number that increments with each frame. %04d places four 0's at the end. The first two images would be named Pic0000.jpg and Pic0001.jpg and so on. You can change this number to suit your project needs.

Once all of the images have been captured for your time-lapse video, they need to be strung together into one file. To create our time-lapse video, we'll be using Ffmpeg. Download the package using the following command:

git clone ffmpeg

Wait for the package to finish installing. The following command is an example of how to compile the final video:

ffmpeg -r 5 -i pic%04d.jpg -c:v libx264 video-file.mp4

Pic%04d.jpg refers to the image name you set in the previous step. If you changed this name before, change it here. The number after -r will determine how many frames are placed in each second of video. Choose a name for your time-lapse video by replacing the words video-file. Be sure to leave the .mp4 extension.

You can read more about ffmpeg features on the official ffmpeg website here.

To save your work, you'll need to copy the video file from the Raspberry Pi to your own computer. Visit our guide on how to transfer files to the Raspberry Pi.

Congratulations! You created a time-lapse video on the Raspberry Pi.

Converting to GIF

If you'd like, you can convert your video to a GIF using a free tool such as Giphy—though this will reduce the number of frames.

Getting started with the Raspberry Pi OS installation program.
Ash Ash (362)
10 minutes

Update: This article refers to older editions of applications that are no longer relevant to the Raspberry Pi ecosystem. The NOOBS application has been replaced by Raspberry Pi Imager.