2009-02-02, Mon

How to batch create contact sheets from videos

Recently, I’ve had to comb through about a 70 one-hour XviD video clips looking for relevant clips for a certain occasion.

To speed up the “combing” process, I created a contact sheet for each video file, extracting one frame from every 30 seconds of video.

Tool Up

Here are the tools I used:

This whole workflow was done on the Windows platform.

Prepare the workspace

  1. Create a directory where all the work will be done. For the sake of this tutorial, we’ll use the folder d:\videos\.
  2. Copy all your video files to the folder d:\videos\.
  3. Download extract-csheet.js and place it in the d:\videos\ folder.
    This is a command-line script that runs the relevant Quicktime functions with minimal user interaction.

Test run

You should have the following files in the d:\videos\ folder.

  • extract-csheet.js
  • Your video files (video1.avi, video2.avi, video3.avi, etc.)

Open up the Command Prompt change your directory to d:\videos\

C:\Windows\>d:
D:\>cd videos

Now run the script on one of the video files by typing

D:\videos\>cscript extract-csheet.js "d:\videos\video1.avi"

If everything goes right, you should see a Quicktime Player window pop up with your video and a dialog box asking for the Export Image Sequence Settings.

Basically what this does is generate an image sequence from the video file. Format specifies the output file format of the sequence. I used JPEG. As for the Frames per second, here’s the equation:

Frames per second = 1 / (interval between frames in seconds)

A value of 1 would give you one frame per 1 second of video. A value of 0.1 would give you one frame per 10 seconds.

In my case, I wanted a frame for every 30 seconds, so I used a value of 0.03 frames per second (1/30).

When you’re done, clicking OK will start the conversion.

_Note: the script saves whatever settings you’ve entered this time round in a file c:\QuickTimeCodecInfo.xml to be used for subsequent conversions.
If you wish to change the settings, delete the c:\QuickTimeCodecInfo.xml file and run the script again._

When the conversion is done, you’ll find a series of JPEG files in d:\videos\.

video1 01.jpg
video1 02.jpg
video1 03.jpg
video1 04.jpg
.
.
.
video1 99.jpg

Batch it

Now, using Notepad, create a batch file in d:\videos\ called process.bat. In that file, put in a line to execute the script for every video file that needs a contact sheet.

cscript extract-csheet.js "d:\videos\video1.avi"
cscript extract-csheet.js "d:\videos\video2.avi"
cscript extract-csheet.js "d:\videos\video3.avi"
cscript extract-csheet.js "d:\videos\video4.avi"
.
.
.
(process.bat)

Make sure you keep the full path of the video.

Save process.bat in d:\videos\.
Run process.bat from the command line

D:\videos\>process.bat

Go grab a cup of coffee.

Create the Contact Sheet

  1. Open up IrfanView, and switch to “Thumbnail” mode File > Thumbnails.
  2. Browse to d:\videos\
  3. Select the relevent image sequences (e.g. video1 01.jpg, video1 02.jpg, video1 03.jpg)
  4. File > Create contact sheet from selected files…

And there you have it.

Isaac Su

tags: batch clip contact-sheet generate image irfanview quicktime scanning script sequence video

---

Comment

Commenting is closed for this article.

---