« »
April 9th, 2008

LVPE: Processing a Bunch of Photos for Cinelerra

(this post is part of the Linux Video Production Experience series, which chronicles my experiences with creating a high-quality home movie almost entirely in open source software.)

I often augment my video productions with still imagery, since I always manage to take a lot of neat shots on both cameras while I’m on vacation. When I did my editing in iMovie, it was trivial to bring in photos from iPhoto right into my productions. I still use iPhoto to organize my pictures, since I primarily bring my Apple laptop on trips with me, but now that I edit in Cinelerra on my Linux desktop machine, I need to take a slightly different approach to getting images into my videos.

First of all, your average digital photo nowadays is going to be some thousands of pixels wide and tall. My camera can easily shoot 1600×1200 pixel images, and I know it can go a little higher. Importing this huge image, unchanged, into Cinelerra will slow down the rendering of this image, both in previews and in the final render, because Cinelerra now has a lot of pixel data it needs to scale/throw away. Now, if you have one or two photos, you can use The GIMP to scale a picture down, probably to no more than 1000px on the image’s longest side, and then import that into Cinelerra. However, I typically use about one or two photos overall for every minute of footage in the movie. This latest movie used a little less — only about 10 photos — but I still didn’t like the idea of scaling 10 photos, one at a time, in The GIMP, especially since I have such easy access to ImageMagick. :)

Make sure a fairly new version of ImageMagick is installed. Take all of your photos, touch them up individually as necessary, and stick them in a folder, unresized, called “Images”. Create another folder along side, not inside, “Images” called “ResizedImages”. Now, open a bash shell and cd to the directory that contains these two folders and run this script:

for i in Images/*; do
  filename=$(expr "$i" : '^.*/(.*)$')
  convert "$i" -filter Lanczos -resize "1000x1000>" -quality 80 "ResizedImages/$filename"
done

This will scale each image down to be no more than 1000px on its longest side, keeping the original file format (most likely JPEG), and with a quality setting of 80. It will scale the images using the Lanczos filter, which is pretty good at keeping sharp areas sharp when shrinking images. This should give you enough pixel data to make high-quality Camera & Projector moves in Cinelerra, while keeping down the rendering time. If the photo doesn’t look good after the scaling process, use The GIMP to scale it and use the Bicubic filter when scaling and see if that does a nicer job.

Before importing any images into Cinelerra, hop over to the Settings -> Preferences window and, under Recording -> Images, enable the checkbox next to “Import images with a duration of” and set the duration to something reasonable, like 5 seconds. Otherwise, your images will be imported with a length of one frame. It’s true!

One additional problem: if you’re editing a movie in 16:9 aspect ratio, and you import an image that’s 4:3, it’ll be stretched. You can fix that using Cinelerra’s Scale filter on that track (I find it’s best to keep my photos to one track only, so I can easily apply the Scale filter to that track and so I can more easily manage the Camera & Projector). Set the X Scale to 0.8880 and the Y Scale to 1 and your pictures will look just fine. This is not an issue if your video is 4:3. I’m not much of a fan of using ImageMagick to adjust the aspect ratio of the images. The Scale filter works just fine for me.

2 Responses to “LVPE: Processing a Bunch of Photos for Cinelerra”

  1. heathenx Says:

    Interesting.

    You already have image resizing figured out but perhaps you would be interested in KIM (http://bouveyron.free.fr/kim/index.html) for KDE and/or NIS (http://www.creationgif.com/debian/nis/) for Gnome. I use both and find them rather handy when I need to batch resize. They are basically front ends to ImageMagick.

  2. johncoswell Says:

    Oh, wow, much easier! Thanks for sharing those! :)

Leave a Reply