A Better Time-lapse Photography Script

CanSatLogoMy first attempt at a time lapse script came up a little short.  That script was intended to be quick and dirty.  In order to make it easier to use, I’ve written some improved scripts.

Our CanSat is designed to start taking photos when the Raspberry Pi starts, and it will keep shooting until we pull the plug (or it runs out of disk space).  On competition day, we don’t want to have to log into the Raspberry Pi to start the process.  Ideally we would have it start automatically at start-up time.

While our first attempt achieved this, it wasn’t designed with the consideration that someone might like to use the Pi for something else while the time-lapse script was running.  Some comments on the original post suggested this was a problem.

Finally, the preview pane was enabled by our last script, so as photos were being taken, the screen would become obscured.  I’ve also addressed this in the new scripts.

To address these concerns, I’ve reworked the script so that is becomes a system service.  We no longer need an additional user, or to modify the /etc/inittab file to allow for automatic login.  The init script allows the system to start the service at boot time, and stop it at shut-down (if it is so configured).  We can also better monitor when it is running, and start and stop it more easily.  Suppressing the preview pane also helps allow the Pi to be used for other uses while photos are being taken.

Better time-lapse photography scripts are available on GitHub.


Tags: , , , , ,

3 responses to “A Better Time-lapse Photography Script”

  1. Masumi Yamamuro says :

    Hi, Chris.

    I had a great success with your first version of timelapse camera. Now I am in the process to move on to your “better ” one.

    I need a help.

    I put timelapse-daemon to /etc/init.d/, timelapse.conf to /etc/default/, timelapse.sh to /usr/local/bin, and did ‘sudo chmod 755 /usr/local/bin/timelapse.sh’.

    Everytihing was good up until here.

    When I did ‘sudo update-rc.d timelapse-daemon defaults’, I got a message saying ” update-rc.d: using dependency boot sequencing . insserv: script timelapse-daemon is not an executable regular file, skipped!”

    I rechecked spelling, rewrote many times, but I always got the same message.

    Could you kindly give me an advice ?

    • ccollins says :

      Hi Masumi,
      The service script (/etc/init.d/timelapse-daemon) also needs to be executable. You can ensure it is by using ‘sudo chmod 755 /etc/init.d/timelapse-daemon’. I suspect that this had not already been done, and this is causing the error you’re seeing when you run update-rc.d. Once the service script is executable, retry running the update-rc.d command, and it should be successful.

      Can I ask what your project is?

      Only after writing this blog post, did I find that raspistill supports a timelapse function anyway, so depending on your needs, setting up a system service to take photos might be overkill.

      For example, running
      raspistill --timeout 30000 --timelapse 2000 --output image%04d.jpg will take a shot every 2 seconds for 30 seconds (times are given in milliseconds). Setting up a service is only useful if you need your Rasbperry Pi to start taking photos automatically after a reboot or start-up.


  2. Masumi Yamamuro says :

    Hi, Chris. Thank you very much for you kind and quick replay as usual.

    I did ‘sudo chmod 755 /etc/init.d/timelapse-daemon’. Yes, it started warkingbeautifully!

    To start taking photos automatically after a reboot or start-up is exactly what I want. I am going to take timelapse camera to outdoors. Although I put 1.5′ screen for preview ( which is very helpful), I don’t want to bother putting command from key board once I go outdoor.

    Again, thank you very much indeed!

%d bloggers like this: