Return to Ferret FAQ


Making MPEG Animations


Question:

How can I make MPEG animations using FERRET?

Solution:

Making mpeg animations with ferret is a relatively simple, albeit a multi-step, process. There are two basic methods of making animations. One method involves saving ferret snapshots as GIF files, and while the other writes ferret snapshots in the HDF file format. In both cases, additional software is needed to complete the bridge between ferret snapshots and mpeg animations.

NOTE: There is a simple method to make GIF animations, described at the start of the section on animations, in the Ferret Users Guide. Please see "animations, creating" in the index to point you to the "Note on using whirlgif to make a movie". This section outlines how to use the public-domain whirlgif software to make a set of gif files into a gif animation.

MAKING MPEG ANIMATIONS USING GIF FILES
---------------------------------------

o  PICKING UP THE SOFTWARE

First the mpeg encoding software must be picked up.  It can be found at:

	Berkeley MPEG tools

on the page:
	http://bmrc.berkeley.edu/frame/research/mpeg/


That page contains links to binaries for several systems, and if there
exists a binary for your desired system, I recommend picking it up.
The source code also exists and can be downloaded and compiled/linked
if necessary

Also needed is the routine "giftoppm".  this can be found in the
pbmplus package, which can be picked up from:
	
	Acme.com

There may be a newer version of the pbmplus package, but this one does work.

Once these are picked up, compile and build the executables.


o CREATE GIF FILES VIA FERRET

The naming scheme FERRET employes meshes perfectly with the
methodology of the mpeg encoding software.  To create a bunch of gif
files in FERRET, simply:

	yes? set data xxxxxx
	.
	.		! set up plot desirables, etc.
	.
	.
	yes? repeat/l=1:25 (shade var; frame/file=movie_frame.gif)
	yes? exit

This will create 25 gif files, named:
	
	movie_frame.gif
 	movie_frame.gif.~1~
 	movie_frame.gif.~2~
	.
	.
	etc.

o RUNNING MPEG_ECOCDE

Once the gif files are ready, all that remains before creating an mpeg
is setting up the paramater file which mpeg_encode uses to find the
gif files, etc. The README file included with mpeg_encode software
will elucidate this process.  Also included are a couple of example
parameter files to help guide the way.



MAKING MPEG ANIMATIONS USING HDF FILES
--------------------------------------

o  PICKING UP THE SOFTWARE

The software used to convert hdf files to mpeg streams is called,
surprisingly, hdf2mpeg. There are actually two parts to this software.
One part is a converter which takes the hdf file and converts the
images into YUV files.  The second part is an mpeg generator called
"mpeg", which takes the YUV files and creates an mpeg stream.  Both of
these can be picked up at NCSA's ftp sight, in the directory:

	ftp://ftp.ncsa.uiuc.edu/HDF/HDF/contrib/NCSA/HDF2MPEG/

and the archives to pick up are:

	MPEGv1.1.tar.Z		        ! Stanford Mpeg code
	yuvconvert.shar			! hdf to yuv code
	MPEGDOCv1.1.tar.Z             ! documentation

There is also a README file you may want to look at.

Again, once these are downloaded, compile and link as necessary.  The
resulting binary files of interest will be:

	yuvconvert 	! converts the hdf file to YUV files
	mpeg		! converts the YUV files to mpeg stream


o CREATE HDF FILES VIA FERRET

Creating HDF files is similar to creating gif files, except when
saving the graphic frame, use an ".hdf" extension rather than a ".gif"
extension:

	yes? repeat/l=1:25 (shade var; frame/file=movie.hdf)


One hdf file is created which contains all of the frames of the movie.
This can become quite large with a movie of many frames. 


o RUNNING HDF2MPEG

hdf2mpeg is simpler to run than mpeg_encode because it needs no
parameter file.  The usage of yuvconvert is:

	Usage: yuvconvert hdfFile outFilePrefix [xdim ydim]

so for our example:

	%   yuvconvert movie.hdf mpeg_movie

will run the convert program and then, once the YUV files are created,
will automatically call the mpeg program to create an mpeg stream
called mpeg_movie.mpg.  Also a bunch of files named
mpeg_movie.*.[YUV] will be created, but these can be deleted once the
mpeg movie generation is finished.

One desirable feature of hdf2mpeg is that the output size of the mpeg can
be specified on the command line.  For example:

	
	%   yuvconvert movie.hdf mpeg_movie 100 100 


will create a mpeg which is 100x100.


Last modified: Feb 9, 2006