How to | Import and Export Animations
| After creating or editing an animation in Mathematica, you can export it for use in other programs. Mathematica can import and export animations in several formats. | |
This is a selection of examples from the complete
"How to" screencast. »
View the elements available for
Import in a QuickTime file in the
Mathematica documentation ExampleData directory:
| Out[1]= |  |
Import the QuickTime file as an animation:
| Out[2]= |  |
Use
Length to see how many frames are in the animation:
| Out[38]= |  |
Import a specific frame of the animation:
| Out[35]= |  |
Use

to import all of the frames in a list. You can do the same thing by using

in place of

:
Use
ImageResize with
Scaled to make each frame half its original size:
Use
Sharpen on each of the frames:
Use
ListAnimate to make a new animation from the processed frames:
| Out[29]= |  |
Export the new animation to SWF, which is a format based on Flash. The

symbol specifies the most recent output, which in this case is the animation:
| Out[11]= |  |
If you open the exported animation, you will see that it contains non-functional controls across the top. The animation is essentially a movie of a movie. To exclude these controls from the exported animation, simply export the list of frames directly to a file format supported by animations.
Here, the list of frames (stored in the symbol g3) is exported directly to SWF:
| Out[12]= |  |
You can also import and export animations that you create in
Mathematica.
First, use
Table to create 5 plots of

where

:
| Out[3]= |  |
Use
ListAnimate to create an animation from the list of plots:
| Out[4]= |  |
As before, exporting the list of frames (in this case the plots) directly to a file format supported for use in animations creates an animation of the frames:
| Out[29]= |  |
Once an animation is exported, you can also import it back into
Mathematica:
| Out[30]= |  |
You can also export
Manipulate objects as animations.
Use
Manipulate with
Plot3D to create an interactive 3D plot of

, where the value of

varies from 0 to 4:
| Out[66]= |  |
The next three steps are equivalent ways to export the entire
Manipulate object, controls and all, to an animation.
Here the most recent output, which is the
Manipulate object, is exported:
| Out[67]= |  |
The
Manipulate is also stored to

, so exporting

produces the same result:
| Out[68]= |  |
You can also put the
Manipulate expression inside the
Export expression:
| Out[69]= |  |
The animations

,

, and

are identical. They also contain the framing and controls typical of
Manipulate objects in
Mathematica.
To export animations that lack the framing or controls, you should generate a list of graphics representing a suitable number of steps used in the
Manipulate, and then export that list to a file format used for animations.
For example, use
Table to create a list plot of

, and specify that

should move from 0 to 4 in steps of 0.2:
Export the list of graphics to the file

:
| Out[71]= |  |
You can create a longer, smoother animation by reducing the step size used in
Table. For instance, reducing the step size from 0.2 to 0.1 will result in twice the number of plots in the list, and subsequently twice the number of frames when it is exported as an animation.
Correspondingly, the file size of the animation, as well as the time it takes
Mathematica to create both the plots and animation, will approximately double.