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.

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

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'.
This can probably also be done with iMovie, but I've never tried it.

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.