Creating a mp4 movie from IDL

For presentations or web-pages I often need to create movies showing, e.g., the evolution of solar feature with time. This page explains how I do this.

The best format to use these days is mp4, and if you want to create a movie for presentations, for personal use and mailing to others, then you can create the movie directly from IDL.

A problem comes if you want to create a movie for a webpage. Some browsers are fussy about how the mp4 is created. In general you should use the h.264 codec. However, IDL does not create movies with this codec. To proceed you should write out individual image frames and then string them together into a movie using separate software. I've been using Quicktime 7 Pro (see below).

Creating a mp4 movie from IDL (the IDLffvideowrite object)

This is straightforward if you make your graphics with the IDL plot objects. I've written a separate webpage that gives an example.

QuickTime and iMovie (Mac)

Modern Macs come with QuickTime X pre-installed, but (as far as I'm aware) it doesn't allow images to be combined into a movie. QuickTime Player 7 is an older version of QuickTime that Apple still distributes and is compatible with old movie formats. It also does not allow images to be combined into a movie. However, it can be upgraded to QuickTime 7 Pro and this does allow you to make movies. Unfortunately it seems it's no longer possible to buy the Pro registration keys (they're not listed on the Apple site). You could check with your IT department or colleagues if they have an old registration key that you could use (note the keys don't expire).

UPDATE (2018): it seems Apple doesn't allow you to upgrade to Pro even if you have a registration key. I think the only way to get Pro working is to install Quicktime 7 by using the Time Machine backup from a machine that does have Pro (not confirmed yet).

Another option is to try using the iMovie software that comes with modern Macs, but I haven't had any success in getting this to work.

My method (for a Mac)

My method for creating a good movie is to write out individual image frames from IDL using plot objects. In particular note that any plot object, p, can be written to a png using:


The resolution=96 ensures the output image has the same size as the image displayed on your screen.

After I've created a set of images (I usually call them image0000.png, image0001.png, etc.), I then use QuickTime Pro (Mac) to read the images into a movie. I do the following steps:

  • Click on File -> Export...
  • Select 'Movie to MPEG-4' option, and click on the 'Options...' button.
  • Select File Format 'MP4', and Video Format 'H.264'.
  • Data Rate should be set around 2000 kbits/sec.
  • For 'Image Size' use 'Current'.

Embedding the mp4 in html

To embed the mp4 movie in a webpage, you need to use the html5 video container. I suggest going to one of my webpages and viewing the page source for the video on this page to see how it works.

The option "controls" will display play and stop buttons when the movie is played, while "loop" makes the movie automatically loop.

Page maintained by Dr Peter R Young.