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 process. Please note that I make use of QuickTime Pro for Macs.

Format

The ideal format for a movie is mp4, but it must be created with the h.264 codec. In this format the movie should play with any web browser. There are many other codecs, but there is no guarantee that these will work on all web browsers.

Although it's possible to create a mp4 movie directly from IDL (see the IDLffvideowrite object below), they will not be created with the h.264 codec and so the movies will not work with all browsers. (The movie will be fine for personal use, such as presentations, though.)

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).

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:

IDL> p.save,'image.png',resolution=96

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.

The IDLffvideowrite object

mp4 movies can be written directly from IDL, however not with the h.264 codec so they are not useful for webpages. For information on how to use the object, please check the information given at this location.



Page maintained by Dr Peter R Young.