Mar 22

Often, you’ll have a sequence of image files from which you’d like to make a movie that plays in PowerPoint for presentations. The best way I’ve found to do this is to create Windows Media files. Here is the recipe I’ve found that works well using Windows XP. You’ll need to download ImageJ and Windows Media Encoder. Your mileage may vary.

  1. Open ImageJ (version 1.41 or above is recommended). Load the sequence (File->Import->Image Sequence…). The length of the videos you can create is limited with this method, but it works well enough for videos that are under 10 seconds long. You should be able to encode longer still frame sequences by opening the image sequence as a virtual stack.
  2. Crop the video so that the width and height of the videos are even numbers. Otherwise, Windows Media Encoder will save that the AVI is not valid.
  3. Save the image sequence as an AVI file (File->Save As->AVI…). Choose JPEG as the compression method and set the quality to 100. Set the frame rate to something reasonable (e.g. 10, 15, 30 fps).
  4. Open Windows Media Encoder. In the New Session wizard, choose “Convert a file”. Set the source file to the AVI you exported from ImageJ. Set the output file to the name you want. Click next. Choose the type of content distribution you are targeting. For playback in PowerPoint, choose “File download (computer playback)”. Click next. This will result in the highest quality video. Under encoding options, choose something suitable. I choose “High definition quality video (5 Mbps VBR)”. Click next. Name the video and click next. Under the “Settings Review” panel, uncheck the “Begin converting when I click Finish” checkbox and click Finish.
  5. Before doing anything else, we’ll change the size of the output video. Click on the “Properties” button in the toolbar at the top of the application window. Click on the “Video Size” tab. Under the “Crop” settings, choose method “Custom”. Under the “Resize” settings, choose “No resizing” unless you want the video to be resized. When finished, click “Apply”.
  6. Finally, click the “Start Encoding” button in the toolbar. You’ll see a preview of your video as the encoding proceeds.

That’s it. Now test out your video in PowerPoint and make sure it plays in presentation mode.

Nov 12

ImageMagick’s ‘convert’ program makes it easy to stitch together two separate images so that they appear side-by-side in another image. This can be very useful for making demo videos. The command is simple:

convert image1.png image2.png +append output.png

That’s it. The command assumes image1.png and image2.png are the same height.

To apply this command to a sequence of images and get a sequence back, it does not work to do the following:

convert image1*.png image2*.png +append output.png

This actually appends all the specified images into a single frame. Instead, you can write a simple shell script to run the command many times. This one runs in bash:

n=0;
while [ $n -lt 180 ];
do
   printf -v file1 "ModelResized/spindle-model%04d.png" "$n";
   printf -v file2 "Simulation/spindle-sim%04dG.png" "$n";
   printf -v outFile "output%04d.png" "$n";
   convert $file1 $file2 +append $outFile;
   n=$[$n+5];
done;

It’s kind of ugly, but it works. One thing to note: printf works just like the C function printf. The -v VAR option stores the formatted string output into the variable VAR.