Introduction: Time Lapse Camera Rig

My time-lapse rig uses a first gen' Pi + a very cheap USB webcam + a free stand (bipod). Part of my build criteria is to reuse/up-cycle stuff I've already got, otherwise I'd have just gone out and bought a Pi camera module and used this project guide. Oh.. and it all had to be run via the terminal - as I envisaged that most/all of the post processing would be done remotely (headless), or not using a network.


Costs & equipment:

  • RPi 1st Gen = £5:00
  • 16GB SD Card = £5:00
  • Power supply = £4:00
  • USB webcam = £1:00
  • CAT5 ethernet cable = free
  • Bipod = free

Step 1: Step 1: Install Fswebcam

NOTE: I used a 16Gb SD card with a clean install of current OS Raspbian (Buster desktop version). I use Etcher to flash my cards.

Start by installing fswebcam, as described in this RPi documentation.

sudo apt install fswebcam

Plug in your cheap/spare webcam and test it using:

fswebcam -r 800X600 image.jpg

If that works ok, create a directory to hold your masses of images.

mkdir webcam

Step 2: Step 2: Create Bash Script & Automate

All the commands done using a terminal window / command line.

Create a bash script in nano (called Create the empty file by typing:


Finished bash script:


DATE=$(date +"%Y-%m-%d_%H%M")

fswebcam -r 800x600 --no-banner /home/pi/webcam/$DATE.jpg

Use this command to make it executable:

chmod +x

Test the script using this command:


Automate the process using cron (good explanation here).

Type in the following command in the command line, the go to the bottom of that file and type in the second command:

crontab -e

* * * * * /home/pi/ 2>&1

There is even a handy online crontab generator which does all the thinking for you:

Save and exit the text editor. Reboot, set up your webcam and go. This script now takes an image every two seconds (everyday) with a unique time-stamped filename at res’ 800X600 all dumped in your webcam folder.

Step 3: Step 3: Check Your Images

Within the webcam folder type:

watch ls

This displays the folder contents with a real time update.

I wanted a quick way to cycle through (some of ) the images using a command line (to check them before encoding). Type in:

sudo apt-get update

accept all prompts

Then type:

sudo apt-get -y install fbi

To play a swift (1 second per image) slideshow of images use the syntax (when connected to a monitor):

fbi -a -t 1 *.jpg

Note: “FBI only works from the command line with no other graphical interface running. So if you boot straight to the command line it will work fine. If you boot into the desktop and then use a terminal window it will not.”

Thanks must go to the Raspberrypi-spy guy for this note & the fbi idea.

Step 4: Step 4: Encoding & Playing the Video

Install FFMPEG - which is a serious piece of video editing kit. FFMPEG can be wrangled from the command line (if you know what you're doing!). Install it:

sudo apt-get install ffmpeg

Convert your jpegs to a movie use the syntax - within the webcam directory:

cat *.jpg | ffmpeg -r 20 -f image2pipe -i - output.mkv

So this pipes out the list of jpegs into ffmepg to process; at framerate of 20, out to finished video output.mkv or mpg/mp4, etc.. There are many more variables you can tweak using switches to modify the output of your video!

This was by far the simplest method I found - and thanks must go to Luke Smith for his video on the topic. There are other methods, and the ffmpeg help pages also provide some good examples.

To play the video from command line, I use VLC media player.

Do this by typing:

vlc --zoom 0.5 --loop video.mkv

This plays the video at 0.5 scale looped until you press CTRL + C to abort the script. I've found that this works best if you go to desktop mode (startx) then open a terminal window. Otherwise older versions of the pi will drop frames from large / hi rez videos. The VLC media player has a comprehensive set of commands - similar to ffmpeg, to run from a terminal window.

Step 5: Step 5: Remote Access to Pi

To run scripts, close down the pi, and transfer files I used two Windows applications and a CAT 5 ethernet cable.

Access to the Pi was done using a Cat 5 cable, as I thought it provided a quick and easy way in. I'd envisaged my camera rig in the shed or outside on some occasions (without a network). So a physical connection seemed ideal, until I set up a static IP address and use a phone hot spot!

So simply plug the cable into your pi and laptop/PC. Install these two free softwares:

I used Putty to run the ffmeg scripts and shutdown the Pi (sudo shutdown now). Boot up Putty on your Windows PC. In the Host Name type in the name of your Pi followed by .local. i.e mine is:


Click the Open button, then follow the prompts for name & password. Then you're into the Pi at terminal level, perfect for running scripts and navigating around directories.

To copy or move the videos from the Pi to my laptop I used WinSCP. This acts in a similar manner, in terms of entering your address of the pi ending in .local, and following the prompt to enter your Pi password.

Then simply drag files from your Pi (right) to your Windows laptop (left).

Step 6: Step 6: Output Videos

The two examples I experimented with, are shown below. Both were rendered out as *.mkv which gave good results, as did the *.mp4 CODEC. It appears the *.mpg/Mpeg video format has been superseded. Both videos were captured on grey stormy days – so the clarity is passable. Jpgs were captured at 650X480. I’ll experiment with higher rez jpegs and differing frame rates when rendering videos.

Thanks to Andy & Emily @ Telford Makerspace for their help along the way.

Raspberry Pi Contest 2020

Participated in the
Raspberry Pi Contest 2020