Malcolm Slaney, "MakeQTMovie - Create QuickTime movies in Matlab," Interval Technical Report 1999-066, 1999.

Malcolm Slaney, "QuickTime tools for Matlab," Interval Technical Report 1999-066, 1999.

Enclosed are two functions for reading and writing QuickTime movies in Matlab. The creation function converts Matlab plots, arrays and sound into a QuickTime movie. The reading function parses QuickTime movies, decodes the JPEG images, and returns the sound.

This code is more general then previous methods for creating movies in Matlab. Macintosh Matlab can create QuickTime movies, using the direct calls in the operating system, but this feature is limited to the Mac. There is also C code and a MEX file which creates MPEG files, but these routines do not allow you to add sound.

The ReadQTMovie program only reads movies compressed with the JPEG image format. Motion JPEG and the other more advanced codecs are NOT supported.

Since this code is an m-file, it runs on any Matlab platform. It has been tested in Matlab 5.2 on Macintosh, Windows, Linux, and SGI computers.

****************** MakeQTMovie ********************************
Syntax: MakeQTMovie(cmd [, arg])
The following commands are supported:

addplot - Add current figure to movie (with axis)
addframe - Add current figure to movie (no axis)
addmatrix data - Add a matrix to movie (convert to jpeg with imwrite)
addsound data - Add sound to movie (only monaural for now)
cleanup - Remove the temporary files
demo - Create a demonstration movie
finish - Finish movie, write out QT file
framerate fps - Set movies frame rate [Default is 10 fps]
quality # - Set JPEG quality (between 0 and 1)
size [# #] - Set plot size to [width height]
start filename - Start creating a movie with this name

The start command must be called first to provide a movie name. The finish command must be called last to write out the movie data. All other commands can be called in any order. Only one movie can be created at a time.

****************** ReadQTMovie ********************************
Syntax: im=ReadQTMovie(cmd [,arg]);
The following commands are supported
start filename - Open the indicated file and parse its contents. Must be called first.
getframe num - Return the image indicated by this frame number. Returns an empty matrix if this frame does not exist.
getsound - Get all the sound for this movie
getsoundsr - Get the sample rate for the sound in this movie
close - Close this movie.

Note: The ReadQTMovie command can only read JPEG compressed movies.

****************** Support ********************************

This code is unsupported. I use it in my work and I certainly want to hear about bugs, fixes, and enhancements. But I can make no promises of any kind for support.

-- Malcolm Slaney Interval Research Corporation