Jun 22

Setup a the Time Lapse Example and Create a Video

Hi In this post I will try to explain how I set up the Raspberry PI to take time lapse images and create full 25 fps videos.

Example output:

You Will Need:

  1. Raspberry PI
  2. Camera Module
  3. PC to create the video files.


I will assume you have the Raspberry PI and camera module installed.

I personally use a laptop with WinSCP & Putty installed to remote admin the Raspberry PI. this allows me to position the PI anywhere I can get a wireless signal or patch to a network. (Tutorial coming soon!)

Log in as root. In your home directory create a file called timelapse – type the following lines of code:


while [ "$NUM" -lt "$TOTALF" ]; do
filename=$(date -u +"%d%m%Y_%H%M-%S").jpg
raspistill -w 1280 -h 800 -t 0 -o $SAVEDIR/$filename
NUM=`expr $NUM + 1`

Save it and return to your command line.

You easily can modify the code: TOTALF being the number of frames to take and SLEEPTIME is the number of seconds to wait between shots (This is approximate – you need to add on the time it takes for the camera to take the image and store it – about 2 seconds) The resolution can also be changed in the above example its set to 1280 x 800.

Create a folder in your home directory called stills – use WinSCP or with command line/Putty – something like:

mkdir /home/stills

You are ready to start taking pictures!

To launch the script (directly from the PI or you can putty/ssh in)

Login and go to the home directory:

cd /home

Run the script… (You will need space on your memory card!)


If you used the settings I left in the script it will take approx 7 hours to run and eat around 900MB of space on your memory card.

Time Lapse Raspberry Pi

Screenshot: The Timelapse scriptis running….

If you want to stop it early press CTRL+C to jump out of the script.

When the script is done the stills folder will be full of date stamped images…

To process the output and make a video…

To make this easy I am using a Windows 7 Laptop with WinSCP and Putty…

Connect to the Raspberry PI using WinSCP – You need to copy all the images from the PI to the PC. Navigate to /home/stills (in the right hand pane). On the left hand side Navigate to a folder to copy the images to.

WinSCP Copy files

Copy all files from the PI to a Windows folder…

click on one of the image files in the stills folder  then press CTRL+A to select all files. Drag them all in one move to the windows folder on the left.

Depending on the image size and number of images this may take some time! (using the script defaults 900MB took around 7mins)

Now you have all the images on your PC we need to rename them to process. I like to use the Bulk Rename Utility as it offers many great features and is also free! Download and run the application (No install version works fine for me!) and navigate to your folder full of images. SORT THEM BY DATE! else the images will be out of sequence!

With the files listed in date order – press CTRL+A to select all images. Of all the settings below we only need to change 2…

Set the numbering mode to “Suffix” and File to “Fixed” (Type a filename). you should see the new name in green with a name and number with increment. (See below)

Bulk Rename Utility

The Bulk Rename Utility – highlights where to change settings.

When all looks good press the Rename button at the bottom right and the files are renamed. Close the app…

Create the video

At this point I would recommend you have xvid installed to create encoded video files – this is not essential but will help save a lot of disc space!

To encode the video I am using VirtualDub a great FREE video processing tool.

Install and run VirtualDub.

From the file menu pick Open Video file. Navigate to your folder of images and click the first one. set the file type to Image Sequence:

Open Image Sequence

VirtualDub Open Image Sequence

click Open and the whole sequence of images will load into VirtualDub.

Select Video->Frame Rate menu item and set the frame rate (I set mine to 25fps)

Video framerate

Set output Video Framerate

Next – Set the video compression – on the Virtualdub menu select Video -> Compression.  I set mine to xvid for a smaller output file if you do not have this select cinepak/intel/microsoft.

VirtualDub video comression

Select Video Compression format

Finally select File -> Save as AVI and give your final output a filename.

Virtualdub in action

VirtualDub Creating the final AVI Video file.

The video is now ready to watch using Windows media player, VLC or transfer to your media device. This file can also be uploaded directly to youtube – depending on your internet bandwidth you may need to scale the images down or shrink the video further as the output files can quickly become quite large!

Final Video Image

The Final Video

Have fun!

May 28

Configure the LAN Network on your Raspberry PI

So you’ve powered on your PI and booted from the SD card. If you do not have any internet/network connectivity this may help…

you can check your network devices are installed and have a driver configured by typing the IP command:

ip link show

This will show all network interfaces currently connected to your PI. LO is the local host for internal IP traffic. eth0 is the on board RJ45 connector. wlan0 (if connected) is the USB wireless dongle. Your output should be similar to this:

root@raspberrypi:/# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN mode DEFAULT
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
 link/ether b8:47:eb:33:24:53 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DORMANT qlen 1000
 link/ether 80:1f:49:ff:38 brd ff:ff:ff:ff:ff:ff

As long as eth0 appears on the list your on board network adapter is ready to be configured:

  1.  log into your Raspberry PI using the root account.
  2. At the prompt type:
cd /etc/network

then to edit your network interfaces type:

nano interfaces

check your network interface is configured correctly:

If you are using DHCP from your router: (The address is issued by your router- normally the default)

auto lo

iface lo inet loopback

iface eth0 inet dhcp

If you are going to fix the IP address you need something like:

auto eth0
    iface eth0 inet static

You will need to modify the above IP addresses to match your current router configuration.

When you have finished configuring your interface you can exit out of “nano” (the text editor) by pressing CTRL+X  It will prompt to save changes.

Much more detail can be found on: http://wiki.debian.org/NetworkConfiguration

To restart the interface you type:

sudo /etc/init.d/networking restart

you can individually bring down interfaces using

ifdown eth0

and re-instate them with

ifup eth0

Once your network interface is up and running you can test it by issuing a ping command to your router:


And to check you can get out to the internet a ping to a popular site:

ping www.google.com