Resman says hi.

Timelapse with CHDK and Avisynth

Table of contents

A timelapse is an animation technique that consists in shooting frames at a certain speed and playing them back much faster, giving a greatly accelerated video effect. This allows to see happen in a few seconds phenomenon that normaly take hours, days, or months. It's great fun to watch, and with a little equipment and some patience, it can be quite easy to make your own.

I wanted to use only my point and shoot camera to take the shoots and free software to do the processing on the computer. I used a Canon Digital IXUS 750 (also known as SD550) camera with the CHDK firmware.

Setting up the camera

Timelapse script

You need a camera capable of taking shots at periodic, programmable intervals to take the pictures. Most newer, higher-end cameras have the feature built-in, but you can do it too with a low-end Canon camera provided you install the CHDK firmware. It doesn't actually modify the firmware of the camera, so there is no risk to "brick" your camera and you can go back to the original firmware at any time.

A great feature of CHDK is that it can interpret BASIC or LUA script directly, which allows to completely automate the camera and add features normally only available on the higher-end models. I made a simple LUA script to take pictures at regular intervals. You can copy it below, and save it as timelapse.lua on your memory card (put it in the /CHDK/SCRIPTS/ directory). I only tested it with my Canon IXUS 750, and some features are not available, or behave differently on different cameras, so some tweaking may be in order. However for the most part it should be the same :

timelapse.lua
--[[
@title Time Lapse
@param n Number of frames
@default n 0
@param m Number of frames x100
@default m 1
@param i Interval in seconds
@default i 5
@param d Delay before start
@default d 3
@param r Refocus each frame (1=yes)
@default r 0
]]
 
totalFrames = (n > 0 and n or 0) + (m > 0 and m or 0) * 100
interval = i > 0 and i*1000 or 1000;
delay = d > 0 and d*1000 or 0;
refocus = r == 1 and true or false
 
print( "Shooting "..totalFrames.." frames every "..(interval/1000).."s for "..(totalFrames*interval/1000).."s." )
 
if delay > 0 then
  print( "Starting in "..(delay/1000).."s" );
  sleep( delay )
end
 
if not refocus then
  press( "shoot_half" )
  sleep( 2000 ) -- Allow a little time to focus
end
 
nextTick = get_tick_count() + interval
for i = 1, totalFrames do
  print( "Frame "..i.."/"..totalFrames )
  if refocus then
    press( "shoot_half" )
    sleep( 2000 )
  end
  click( "shoot_full" )
  if refocus then
    release( "shoot_half" )
  end
  sleep( nextTick - get_tick_count() )
  nextTick = nextTick + interval
end
 
if not refocus then
  release( "shoot_half" )
end

The script parameters are :

Launching the script

Example configuration :

Sample configuration
Take 10 000 shots (in other words, take pictures until the memory card is full, or until I decide to stop) at 2s intervals, wait 5s before start, don't refocus each frame.

You can then start the script :

Starting the script
You'll get a quick estimate of the total time and the shooting will start.

Image processing

Once the script ends, you'll hopefuly end up with a few thousand pictures. Now you need to process them into a movie. First copy everything in a temporary folder on your hard drive.

Writing the Avisynth script

Avistynth is a very nice piece of software with allows to process videos through text scripts. It's extremely powerful, but the particular feature we're interested in is that it can use images as a video source.

If you've got a Canon camera like me you should have a directory structure with each directory containing a couple thousand pictures. Assuming you put the pictures in "e:/tmp/lapse/images/", here's what the Avisynth script could look like :

timelapse.avs
ImageSource(file = "e:/tmp/lapse/images/123CANON/IMG_%04d.jpg", start = 2001, end = 4000, fps = 30) +\
ImageSource(file = "e:/tmp/lapse/images/124CANON/IMG_%04d.jpg", start = 4001, end = 6000, fps = 30) +\
ImageSource(file = "e:/tmp/lapse/images/125CANON/IMG_%04d.jpg", start = 6001, end = 7000, fps = 30)
 
# If you wish, you can also resize the images at this step.
LanczosResize(800, 600)
# You can crop too. Make sure the final dimensions are multiples of 8.
Crop(20,20,760,560)
 
# This last step is needed to make sure the image data is in a format friendly to the encoder.
ConvertToYV12()

Since I'm lazy I made a small Python script to create the ImageSource part of the Avisynth script for me. It's pretty much a hack and works only if the images are named IMG_1234.jpg like on my camera. I'm not quite fluent in Python either, but it works. Change the path as needed :

images.py
import os
 
base = "e:/tmp/lapse/images"
folders = sorted(os.listdir(base))
for f in range(len(folders)):
   images = sorted(os.listdir(base+"/"+folders[f]))
   start = images[0][4:8]
   end = images[-1][4:8]
   print( "ImageSource(file = \""+base+"/"+folders[f]+"/"+"IMG_%04d.jpg\", start = "+start+", end = "+end+", fps = 30)", f!=len(folders)-1 and "+\\" or "" );

Video encoding with MeGUI

Avisynth does the frame processing, but not the actual encoding. The last tool we'll need for this last step is MeGUI. It's a very complete x264 encoding suite, and is intended to work with Avisynth scripts. Launch the tool and load our script :

MeGUI main window

Choose encoding settings suitable to your source images and the final video quality. There are many presets built-in but you can make your own if you want. Next click the "Enqueue" Button, and click on the "Queue" tab :

MeGUI jobs

I chose a 2-pass encoding so there are 2 jobs. Now click start to launch the jobs. A progress window will pop up and after a while the final video will be generated.

Troubleshooting : if the job ends immediately with an error check the following :

Final results

Here is a sample video I made. Number of frames : 5000 (2s interval). Speedup factor : 60 (30 fps). Location : Paris, over the Parc Montsouris. Shoot date : 2009-06-11.

You can download the video files directly below :


Comments

Comment left by Ned Diamond on 2020-10-23 11:55:31 :
Vive les microjupes.
Comment left by Sophie Miller on 2020-10-20 18:51:29 :
http://convert-currency.net/
Comment left by Sophie Miller on 2020-10-20 18:51:00 :
Je vous remercie de l'information! Je cherchais et ne pouvait pas trouver. Vous me aidé! [URL=http://convert-currency.net/]convert currency[/URL]
Comment left by Sophie Miller on 2020-10-20 18:50:29 :
Je vous remercie de l'information! Je cherchais et ne pouvait pas trouver. Vous me aidé! convert currency
Comment left by David Winget on 2020-10-19 12:53:22 :
I have gone through this article named 'Timelapse with CHDK and Avisynth'. The article was informative and interesting. The author explained by using examples so we can easily follow it. Thank you so much for sharing this article. CBD Edibles
Comment left by Hunter on 2020-10-07 12:25:20 :
designed to remove luminosity flicker in time lapse photography. Unlike most other flicker removal filters, utilizes cumulative distribution function in addition to average frame luminosity. kitchen renovations manukau
Comment left by Wayne Ogilvie on 2020-10-07 07:49:28 :
What version of CHDK firmware did you used in this timelapse? www.chandlerfencecompany.com offers the most durable fence for you residential area
Comment left by malkov on 2020-09-25 10:31:21 :
Your post has been so helpful because it was clear and concise writing made it easy to understand. Thank you! jiofi.local.html
Comment left by Greg on 2020-09-21 21:15:27 :
Great post- super informational for all of your readers. Thanks for taking the time to put this instructional article together! We appreciate it
Comment left by Bradley on 2020-09-17 20:26:46 :
Ben maintenant, une boîte de cigares, c'est onze balles.
Le squelette de Renescure, il peut aller se rhabiller.
Comment left by Tino on 2020-09-16 10:42:25 :
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Vitrified tiles
Comment left by Franches Love on 2020-09-15 16:11:21 :
This is cool! Thank you .. I hope to see such topics frequently, Thanks again.. Check out our website http://www.tulsaareadesigns.com/
Comment left by accountants Kent on 2020-09-15 08:39:28 :
Very interesting,good job and thanks for sharing such a good blog.your article is so convincing that I never stop myself to say something about it.You’re doing a great job.Keep it up accountants Kent
Comment left by online spiritual courses on 2020-09-15 08:06:05 :
it is really helpful online spiritual courses
Comment left by tree trimming on 2020-09-15 07:59:14 :
You’re doing great work. Keep it up. tree trimming
Comment left by chimney sweep London on 2020-09-15 07:43:39 :
Thanks for the information. chimney sweep London
Comment left by Harry Mathieuws on 2020-09-13 09:23:13 :
Plutôt réussi mon module électronique de teub.
15 Hz, 1OO V, quelques ma, et hop, feu d'artifice.
Mieux que les modules chinois à absorbsion.
Comment left by Bessie on 2020-09-05 08:10:39 :
I will apply this time lapse with my previous work! https://grouponrochester.net
Comment left by Rhainne Coles on 2020-09-02 09:55:04 :
I've tried timelapse in my phone and I was just looked funny and stupid like im in a Retaining Wall Contractors Sacramento
Comment left by Denise J. Farmer on 2020-08-28 23:22:28 :
I hope this can be pretty helpful to all people as they can make it as their screen saver or wall papers on their desktops. This was the best thing I like here so I always visit even busy with my best essay writing service reviews works. We can get good wallpapers here.
Comment left by Avril on 2020-08-27 16:22:13 :
Thanks for sharing this script. LED Headlights
Comment left by suman simgh on 2020-08-25 11:48:54 :
That’s a nice article, thank you for a great article. It helped me a lot. Keep it up Must Visit AVG ondersteuning
Comment left by Scott Heflin on 2020-08-19 06:22:43 :
People essentially claimed all of us simply just what exactly When i opted to help pay attention to help in addition to afterward a lot of. Amazing publishing in addition to regards yet again intended for performing this particular not any fee, see more here.
Comment left by Mary on 2020-08-12 12:40:58 :
Is the script working on all cameras or just this specific camera that you mentioned on the post? Anyway, I really like the output you have based on the attached time lapse video. Anyway, check out this most recommended tree removal Longmont, Colorado has to offer.
Comment left by Jenine Heijink on 2020-08-08 13:51:17 :
Really Nice Post Admin, Very helpful looking for more posts, Now I have to share some information about How To Fix “LexMark Troubleshooting Guide” problem. If you are going through this problem you can simply Lexmark Printer helpdesk
Comment left by Rowanbaartman on 2020-08-01 13:16:38 :
I am really enjoying your site.It’s simple, yet effective, thank you for this article.Now I have to share some information about How To Fix “mcafee Antivirus” problem. If you have any problem rearding Mcafee so click on this site:mcafee antivirus nummer belgie
Comment left by lima wilmink on 2020-08-01 13:13:34 :
I’m really impressed with your writing skills and also with the layout on your blog it's Very interesting to read.Now Here i would llike to share some information about HP Printer If you are facing any problem relate to your HP Printer's we wil resolve your queries at sam time.For any help please visit on our website:hp printer contact belgie
Comment left by Fien Wieten on 2020-08-01 12:18:14 :
I like your blog.You have done Excellent work. I appreciate.Here I want to inform all of you if you are looking for to resolve your Norton Antivirus problems,so you are in right place.we always available for your support.So whenever you need any help so just click on this link- norton Antivirus ondersteuningsnummer
Comment left by MillaRoose on 2020-08-01 12:12:43 :
Excellent post. I certainly appreciate this website.Keep writing.well here if you want to Overcome the issues of Avast antivirus.Pick the Best Assistance over our site to resolve your queries.Visit us :avast antivirus ondersteuning
Comment left by Simon on 2020-07-14 18:10:17 :
Thanks for this. It's really helpful from my bois team.
Comment left by Denner on 2020-03-26 13:26:34 :
Mes microjupes me manquent...
Comment left by Kay Freestone on 2020-03-20 20:00:19 :
Where is your first collaborator ?
Comment left by JP Kevin on 2020-01-13 17:29:28 :
Paraît que 700 boules en avait une grosse, mais que je n'avais rien à lui envier...
C'est Chichid et Makel qui l'ont dit.
Pour l'instant, je fourre l'appareillage dans le short plastique noir bien court.
Comment left by Gugus on 2019-12-09 16:26:44 :
Jamais plus.
9,10 $ pour un paquet de Kamel.
Jamais plus, le squelette de Renescure...
Comment left by Fidèle Didi on 2019-10-25 18:16:06 :
Mi, chu nin écrivain.
Comment left by YoctoSkirt on 2019-07-01 16:47:21 :
Ca y est, j'ai compris.!

Marie qui me dit : il ne doit plus y avoir grand chose à enlever, hein Jean-Pierre !
Et les copains à Hervé qui, par un trou de la palissade, disaient : Ca respire...
Et enfin, Nathalie qui a dit : jamais de culotte, je l'ai vu.
J'ignorais qu'elle parlait de moi à ses amis.
Ben oui, j'aime ça, rien sous le short.
J'ai compris maintenant que j'étais visé.
Comment left by Mlle Bishop on 2018-12-29 20:05:33 :
Vive la micro-jupe.
Comment left by Barsini on 2018-12-02 19:21:55 :
Un peu coincé notre ami Sydney, s'il tenait un magasin de chaussures, il n'aurait que sa pointure en stock...
Comment left by Sofun on 2017-09-17 10:48:38 :
Fabricant.de
Very Nice.
Comment left by Henri Willis on 2017-06-19 18:39:12 :
Je crois que je fais pas financer le speçtacle de mon épouse Grâce Willer ou Rose-Marie Landon...
Comment left by Sander on 2012-07-30 13:10:31 :
Hello,

I finally have the script working on my A480 but even though refocusing is on 0, it does refocus every time before a photo is made..
I've copied the script and used VIM so I'm not missing any 'invisible code'.

Could you possibly help out?

Thanks!
Comment left by fin on 2012-02-20 03:28:37 :
Perhaps if you showed what the final peace looks like so I know what mine should look like.
Comment left by Fin on 2012-02-20 03:20:08 :
Hi there, I have no experience in coding. So trying to copy your .lua i don't actually know what I'm supposed to be copying out of what you have there?
keartan@gmail.com
Add a new comment :
Name :
Comment :

Answer the following question : Which is the biggest, seven or eleven ?