Panning a Timelapse with Lightroom and Perl

Santa Ponsa from Sean McCormack on Vimeo.


Timelapse Panning Video
one hour compressed down to 12 seconds  ·  no sound
by Sean McCormack
( larger high-def version is here )

At right is a short timelapse video (12 seconds, no sound) that Lightroom expert Sean McCormack made from the collection of 300 images he ended up with after setting his camera up on a tripod and having it take a shot every 10 seconds for 50 minutes.

To see the high-resolution version, go here and look for the “four arrows” icon at the lower-right of the video. Click that to put the video into full-screen mode. Then, click the “scaling is on” badge in the upper right to turn scaling off so you see the original size. Then, play the video.

He didn't move the camera during the hour the pictures were being taken, so the original images from the camera were, of course, of one static view. To create the panning effect, Sean used a combination of Adobe Lightroom and little Perl script that I created for him.

I'm publishing the script here in case the more adventurous timelapse makers among you wish to use it. I say adventurous because it's not particularly straightforward, it requires some technical abilities, and it's possible that it could corrupt the images (but you do have backups, right?).

Prerequisites

The instructions assume that...

  • You already have the original frames.

  • You have perl available on your system.

    Macs come with perl already installed. Windows users can get a free version at ActiveState.

  • You can work in a command window (Win) or a Terminal Window (Mac).

  • You know how to convert a bunch of images into a video.

The script itself is here: pan (save as a raw text file; the instructions assume that you name the file “pan”)

Instructions

  1. Make backups of the images. Really.

  2. Load the frames into Adobe Lightroom.

  3. Crop the first frame where you want your pan to start. You'll probably want to use a crop with the same aspect ratio as your target video format. Do not use any rotation because the panning script can't yet handle rotation.

  4. Copy that crop (Ctrl-Shift-C) and apply it (Ctrl-Shift-V) to the final frame. Then, ensuring that the aspect ratio is locked, move/resize the crop to how you want it at the end of the video.

    If you don't resize the crop, but only move it, you'll end up with a simple pan. If you also resize the crop, you'll end up with a zoom-in or zoom-out Ken Burns effect.

  5. Now, apply a crop (any crop) to all the intervening frames. You can, for example, simply apply the crop you happened to have from step #3 above. It doesn't matter exactly what crop you apply because it'll end up getting changed by my script, but you must apply some crop at this point.

  6. Select all the frames, and “Save Metadata to Files” (Ctrl-S).

  7. Now switch to a terminal/command window, and cd to the folder holding the images in question.

  8. Run the command “perl pan” and name all the files for the frames, in order, as arguments. If all the frames are by themselves in one folder, and the images are named sequentially, you can usually get away with simply typing:

       perl pan *.jpg

    with the caveat that you'll have to give the full path to the script (or first copy the script to image folder).

    WARNING: the script writes a new crop directly into the intervening frames, but does so in a way that's not very smart and is very brittle; it could easily screw up and corrupt your images. Be sure to have backups.

  9. Back in Lightroom, select all the frames and “Read metadata from Files”. Lightroom will load the crop info that the script wrote to the files. (The script does not modify the first and last frames, so you don't need to include those frames in this step, but it doesn't hurt.)

You can now export all the frames and create the video. Be sure to resize to uniform dimensions if the pan involves any kind of zooming.

I've never actually done one of these myself (my experiences with timelapse photography is limited to this short cherry-blossom timelapse), but I'll try some day soon. I'd like to see what others come up with, so if you make one, let me know!


All 14 comments so far, oldest first...

Thanks for that. It will be very useful. Sean warned me it was coming before you posted it, so that’s why I had it on my website so fast. Perhaps it can be extended to do gradual exposure compensation to compensate for changes in light (sunsets and such).

— comment by Jao on May 21st, 2008 at 9:50am JST (16 years, 4 months ago) comment permalink

Why not simply drop all photos in a video application like Premiere or Vegas?
That’s much easier and offers far more possibilities.

I think because Sean’s desire to do the panning was less than his desire not to spend hundreds of dollars on a video app with which to do it. If he already had one that could do it, then by all means, that would have been easier. —Jeffrey

— comment by Tibi on May 22nd, 2008 at 5:16pm JST (16 years, 4 months ago) comment permalink

Yep.. I was being suitably tight in this economic downturn.

— comment by Sean McCormack on May 22nd, 2008 at 11:55pm JST (16 years, 4 months ago) comment permalink

This may be heresy on this blog, but Windows Movie Maker is free, and I think would do something similar. No?

Well you answered your own question (“No”), but even if Movie Maker were to do this, it’s “free” only for those who have paid for Microsoft Windows and some hardware to run it on. Sean doesn’t run Windows. Apple’s free (in a comparable sense) iMovie doesn’t allow for it either. —Jeffy

— comment by Michael Friedl on May 23rd, 2008 at 2:50pm JST (16 years, 4 months ago) comment permalink

Help. I can’t seem to save the script as a raw text file. My only options are text file or all files?

Help?

Todd

— comment by Todd on June 27th, 2008 at 4:36am JST (16 years, 3 months ago) comment permalink

Ok. I was able to save it as a text file, but now it is saying can’t open perl script “pan” : no such file or director. I do have it in the right folder though.

TB

— comment by Todd on June 27th, 2008 at 4:40am JST (16 years, 3 months ago) comment permalink

Hi Jeffrey,
Cool script. I don’t know anything about perl but it does look like your script requires that you have to have at least 3 arguments. There doesn’t seem to be any provision for entering the sequence of images in the *.jpg format.

Is there something I’m missing here? Help please

— comment by Lim on September 8th, 2008 at 4:51pm JST (16 years ago) comment permalink

Hmm…couldn’t get it to work. All my files got corrupted and I couldn’t work out what I was doing wrong.

— comment by Lim on September 8th, 2008 at 6:50pm JST (16 years ago) comment permalink

Right-o. Ended up writing my own panning script with the help of ExifTool. Thanks for the inspiration. The script is quite rough since I know nothing about the Perl. I’ll try to refine it and make it a bit easier to use. Who knows…maybe someone else may find it useful.

— comment by Lim on September 9th, 2008 at 9:08pm JST (16 years ago) comment permalink

Lim,
I enter perl pan.pl *.JPG and it works fine for me.

I’ve just created a new movie by splitting the files into subfolders and running varying crops on them to mix pan and zoom and variations thereof in a test movie..

The new movie is literally only a test movie. I changed settings during the capture phase so I’m not pleased with the capture results, but it works as a sample I can try again.

Now if only it could be a plugin!
http://www.vimeo.com/1808623

— comment by Sean McCormack on September 25th, 2008 at 12:32pm JST (16 years ago) comment permalink

I followed the instructions (apart from installing Strawberry Perl) and I got the following error message:

pan: expected three or more images on the command line.

Any thoughts? I don’t have spaces in the path name and all the jpgs are sequential.

Would it be possible to add support for rotation? I can think of several cool special effects that could be done using this. 🙂 Many thanks.

— comment by Jonathon on August 20th, 2010 at 3:47am JST (14 years, 2 months ago) comment permalink

Actually, I ran this serveral times after working out I could get round the problem by listing all the filenames in full. I then found that the script mangled all jpgs apart from the first and last one. Has something really changed in LR3 to stop the script working? Thanks. J

The script is run outside of Lightroom, so shouldn’t really be affected by the Lightroom version. It does some pretty ugly image XMP hacking, but I didn’t think it would “mangle” anything. Perhaps you could send a copy of one unmangled file, and I could look into it… —Jeffrey

— comment by Jonathon on August 20th, 2010 at 8:19am JST (14 years, 2 months ago) comment permalink

Wouldn’t it be possible to do the samethin by a LR-plugin now? LR3 now can also create the Video.

http://www.gwegner.de/allgemein/zeitraffer-lightroom/ has a nice instruction (in German).

— comment by Bernhard on September 6th, 2010 at 3:45pm JST (14 years ago) comment permalink

Finally I finished the first beta of LR-Timelapse, a tool that allows you to make different transitions between development settings in Lightroom – not only crop for pan and zoom but also exposure, white balance and so on.

It comes with a nice user interface so no scripts are needed.

I would be glad if some of you would like to test it an give me feedback.

You can find the project page here: LR-Timelapse

— comment by Gunther Wegner on October 28th, 2010 at 10:33pm JST (13 years, 11 months ago) comment permalink
Leave a comment...


All comments are invisible to others until Jeffrey approves them.

Please mention what part of the world you're writing from, if you don't mind. It's always interesting to see where people are visiting from.

IMPORTANT:I'm mostly retired, so I don't check comments often anymore, sorry.


You can use basic HTML; be sure to close tags properly.

Subscribe without commenting