Time-lapse photography is a technique that has been around for decades. Today, we will see how we can use the Raspberry Pi to create our own time-lapse movies. 

Time Lapse Camera

The principle of creating time-lapse videos is pretty straightforward. It’s a great method of filming something that occurs over a long period of time, such as changing weather or growing plants.

Basically, time-lapse photography requires a camera that is mounted in a fixed position and that is focused upon an object that is slowly changing. A picture is taken periodically, ranging from one image every few seconds to an image every day or week.  

The frequency depends upon how quickly (or slowly) the subject is changing, if you are taking images of clouds moving then you’ll want to do it a couple of times a minute, but if you are filming a plant growing then one or two times per day might be sufficient.

Once a sufficient number of images have been collected, they are joined together and are used as individual frames in a video.

There are many ways to accomplish this, we will see how a Raspberry Pi can be used for this task.  And, best of all, there is no software to install as we will be doing everything at the command line of the terminal.

Required Hardware

You can use any type of Raspberry Pi microcomputer to create time-lapse videos. 

You will need to have the latest version of the Raspberry Pi OS installed on the MicroSD card (or USB stick) that you are using with your Raspberry Pi. As you will be gathering many images, you might want to use a larger MicroSD card to hold them all.

Of course, you will also need a camera, and there are many Raspberry Pi compatible cameras to choose from. I used the Raspberry Pi HQ camera, as it produces great images and also has a 1/4-inch tripod thread, making it easy to mount in a fixed position. 

If you use a different camera, you’ll need to figure out a method of supporting it so that it doesn’t move during filming, especially if filming takes a few days.

Once you have all of that together, boot up the Raspberry Pi and open up a terminal window.

Taking Pictures with libcamera-still

We will be using libcamera-still, one of the apps included with libcamera, which is the new camera stack included with the Raspberry Pi OS. So make sure you have a recent OS build.

If you haven’t used libcamera before, I have created an article and video that explains its use in detail, so you might want to check those out.

Libcamera-still is one of the apps that is packaged with libcamera. As you might have guessed from its name, it is used to create still pictures.

You can use libcamera-still by itself, just make sure your camera is ready and then type the following into your terminal:

You will get a 5-second live preview of what your camera sees. No image will be recorded, it’s just a preview. The preview window will close once the five seconds have elapsed.

You can use this to focus on your subject, although five seconds isn’t really a lot of time to do this. You can extend the preview time by using the “t” parameter, which is the time in milliseconds that libcamera-still is active.

So, for example, this will keep the window open for 20 seconds:

There are a LOT of parameters that you can use with libcamera-still, allowing you to affect almost every aspect of the image. To see them all, just use the help screen:

We will be using just some basic ones for our time-lapse demo, but feel free to experiment with some other ones to improve your image.

Taking Time Lapse Pictures

Here is the libcamera-still command that we will use to take a group of images. The following command will take a picture every 10 seconds for a minute:

You can see what each of these parameters does in the image below.


The files produced will be test0001.jpg, test002.jpg etc., up to test005.jpg  There are five files, as we wait 10 seconds for the first one and end before the last one.

Five files are just for demonstration purposes, in practice, you will need a few hundred files to make a video of any appreciable length.  If we change the command to this, we can get enough for a short video:

This will take a picture every 10 seconds for an hour.  Assuming that your subject changes in some form during that hour, you will now have enough material for an interesting video.

Making a Movie with FFmpeg

Now that we have a bunch of images, we will need some method of using them to create a movie out of them.

This is where FFmpeg comes in handy.

FFmpeg is a command-line utility for creating video files, and we can put it to use in making an MP4 video.

As with libcamera-still, the FFmpeg utility has a wealth of parameters you can supply. To see the list, type the following:

We will be using a few of these parameters to make our movie. Assuming that you have named your image files with sequential numbers and that they are all in the same directory, you can just run this command to make a movie from them:

This will produce a 30fps video called testfile.mp4.

The image above shows how this command is broken down. If you don’t have a large number of images, try reducing the framerate parameter.

Incidentally, you don’t need to restrict yourself to images taken by the Raspberry Pi camera, as any images will do the trick. So if you have another camera, just copy the images to your Raspberry Pi and use FFmpeg to string them all together into a beautiful movie.

Conclusion

By using libcamera-still and FFmpeg we can create amazing time-lapse movies, all we need is an interesting subject and enough time to gather a sufficient number of frames.

So get out your Raspberry Pi camera and go film something wonderful!

 

Time Lapse Camera
Summary
Time Lapse Camera
Article Name
Time Lapse Camera
Description
Learn to use a Raspberry Pi to create amazing time-lapse movies. We will use libcamera and FFmpeg to take timed pictures and stitch them together to create an MP4 video.
Author
Publisher Name
DroneBot Workshop
Publisher Logo

If you have a question...

Comments about this article are encouraged and appreciated. However, due to the large volume of comments that I receive, it may not be possible for me to answer you directly here on the website.

You are much more likely to get answers to technical questions by making a post on the DroneBot Workshop Forum. Your post will be seen not only by myself, but by a large group of tech enthusiasts who can quickly answer your question. You may also add code samples, images and videos to your forum posts.

Having said that, please feel free to leave constructive comments here. Your input is always welcome. Please note that all comments may be held for moderation.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
John Osuchowski
2 months ago

This looks like a project that would amuse me if I can get the damned thing to work.

1
0
Would love your thoughts, please comment.x
()
x