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.
Selected examples from the video:
View the elements available for Import in a QuickTime file in the Mathematica documentation ExampleData directory:
Import the QuickTime file as an animation:
Use Length to see how many frames are in the animation:
Import a specific frame of the animation:
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:
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:
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 ) is exported directly to SWF:
You can also import and export animations that you create in Mathematica.
First, use Table to create 5 plots of where :
Use ListAnimate to create an animation from the list of plots:
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:
Once an animation is exported, you can also import it back into Mathematica:
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:
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:
The Manipulate is also stored to , so exporting produces the same result:
You can also put the Manipulate expression inside the Export expression:
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 :
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.