Software Engineer

order files from multiple cameras chronologically

· by jsnby · Read in about 4 min · (697 Words)
Computers Photography

UPDATE 10/24/2011:

The script has been updated to support Canon CR2 and CRW raw files and JPEGS. I’ve also moved the script to my github account. Find it (and the latest installation instructions) here.

Here’s the situation…’re shooting a wedding, bar mitzvah, or other event. You’re running and gunning, two cameras going full blast, switching back and forth. Your second shooter is laying down cover fire making sure you guys don’t miss any important moments. That’s three (or more) cameras. When you deliver the images to your client, you’d like them to be in chronological order. But how to accomplish this feat?

It’s easier than it sounds and can be done with free software. You’ll have to use the command line, so if you’re not totally comfortable or know what you’re doing, ask a friend that does.

I’m a fan of ExifTool. I’ve written about it before when trying to determine shutter actuations on my D80. If you’re running a Redhat based linux distro, chances are you can install it via sudo yum install perl-Image-ExifTool

Now, before the event, synchronize the clocks on the cameras as close as you can get them. Shoot your events as you normally would. Transfer the files from each camera into separate folders. For this example, I’m going to transfer them into directories called cameraA cameraB and cameraC.

Download this script and save it to /usr/local/bin/order_cron

Make sure that the file is executeable: chmod 755 /usr/local/bin/order_cron

Now, we’ve got the script, we’ve got three folders of images, and we’re ready to go. Open up your terminal and change directories until you are in the directory that is the parent to the cameraA, cameraB, and cameraC directories. For example, if cameraA, cameraB, and cameraC folders are in your Pictures/event_name folder, then change directories like this:

$ cd ~/Pictures/event_name

And you should see your folders by running a list:

$ ls
cameraA  cameraB  cameraC

Make a directory to hold the output images:

$ mkdir outdir</pre>

Run the script. The script takes a few arguments. First, it takes a prefix string. I don’t like how my Nikon names files DSC_XXXX.NEF, so instead of using DSC, my script renames the output files to prefix_XXXX.NEF. I personally prefer not having spaces in my file names, but if you do, make sure to put the prefix in quotes. The next argument is the path (relative or absolute) to the output directory. Then, you can put as many input directories as you want. For our example, I might run the script as:

$ Event_Name outdir cameraA cameraB cameraC

What this does is reads through all of the EXIF data in the files in each of the input directories, compares and orders the files based on the timestamp in the EXIF data, then outputs the files into the output directory in chronological order named something like Event_Name_001.NEF.

If you’re a Canon user, a user that shoots jpeg, or use a camera by some other manufacturer, you can still use this script…you just have to tweak a couple of things. First, if the files are not .NEF files, change the following line in the script to reflect the extension of your files (this is case-sensitive): my $extension = '.NEF';

If the exif data doesn’t contain the ‘SubSecModifyDate’ tag, then you’ll need to update the following line with the equivalent tag for your files:

$files{"$dir/$file"} = getTag($file, 'SubSecModifyDate');

You may notice that I’m simply copying files out of the source directories and into the output directories. This means if you shoot 4G worth of source pictures, you will need 8G total disk space (4G for the source files plus 4G for the files in outdir). I did it this way out of caution…if you type a wrong argument (wrong prefix, for example), it’s easy to just delete the files from outdir and re-run the script. If you’re daring and don’t want to copy the files, but want to move them instead (meaning remove them from the source directory and only keep them in outdir), then change the word copy to move on the following line: copy($file, $newfile);

As stated in the license stanza of the script itself, this comes with NO warranty.