But, once the images are on your Flickr site, what are you supposed to do? You need an easy way to get them back and turned into a time-lapse for whatever period of time you’re interested in. To do this, I’ve created a sample Python script that lets you grab a stack of images for an entire day and create an mp4 from that stack. In this post I’ll walk through that sample code.

In the previous post, I had you install the Python module called flickr_api, so you should be all set on that front. Otherwise, the only modules you need to run the code below are argparse (to parse command line arguments) and os to allow Python to make a system call to an executable (ffmpeg in this case, to make our mp4). These modules ship with Python, so there’s nothing else to install. Here is a sample script (broken down into a few chunks for sake of explanation) to grab a day’s worth of images:

The code above imports some necessary modules and sets up the machinery to parse command line arguments. If you don’t pass it the name of the file to write the video to, it will simply name it with the format yyyymmdd.mp4.

This snippet sets up everything you need to authenticate with your Flickr keys and authentication token. (Here’s a handy refresher if you’ve forgotten about this stuff.) The USER_ID string can be a little tricky since it’s not necessarily the same as your screen name. You can use idgettr to find out what your user id is using your screenname.

This last snippet above loops through a user’s photo sets until it finds the one that matches the PHOTO_SET_ID variable. (If you wanted this code to be super versatile, you could also pass in the photo set id as an argument.) It loops through all the photos in a set and parses their titles (remember, we named the photos according to the scheme yyyymmddhhmm.jpg), grabbing only the photos for the day specified in the command line arguments. (This approach is actually pretty inefficient since it checks all photos in a set. In practice, we know that the photos were likely uploaded in chronological order, so once we encounter photos newer than the date we care about, we should probably stop.) It then creates a local directory for the day requested and saves all photos in that directory, numbering them sequentially (starting at 001.jpg). The final line makes a system call to a video utility called ffmpeg to create an mp4 video at 10 FPS from a stack of sequentially numbered images in the directory we just created.

And there you have it! This script is really just intended to be a quick and dirty example of how you can grab a set of images from Flickr and process them into a time lapse. There are lots of changes you could make to make it more useful, like specifying a time range other than 1 day. So, have at it.