Wolfram Computation Meets Knowledge

Mathematica Q&A: Creating Movie Files

Got questions about Mathematica? The Wolfram Blog has answers! We’ll regularly answer selected questions from users around the web. You can submit your question directly to the Q&A Team using this form.

Here is this week’s question:

How can I create and export movies and animations in Mathematica?

This is something we do often—just about every movie or animation on the Wolfram Blog is created in Mathematica.

If you are creating a movie that you want to include in a web page or send to someone as a standalone file, then the easiest and most interactive option is probably to distribute the movie in Computable Document Format (CDF). To do this, create an interactive animation using a function like Animate or ListAnimate:

Creating an interactive animation using a function like Animate or ListAnimate

Creating movie files

The resulting animation can be saved as a CDF (File -> Save As -> Computable Document (.cdf)) and embedded live in a web page or distributed like any other file. Anyone with the Wolfram CDF Player can open and interact with the animation. The unique advantage of CDF is that you can very easily include additional interactive elements with your animation, such as controls generated by Manipulate:

Easily include additional interactive elements with your animation, such as controls generated by Manipulate

Manipulate

If you want to create a regular movie in a file format such as QuickTime, then the first step is to prepare each frame of the animation. Here’s a function frame[t] generating one frame of animation at time t:

Generating one frame of animation at time t

Visualizing this count as a function of the complex parameter c

The function bounditerations[c, t] counts the number of times that repeated applications of the complex function zz^t + c (starting from z = 0) stay inside the region |z|<2. The function frame[t] visualizes this count as a function of the complex parameter c: the horizontal axis is Re[c] and the vertical axis is Im[c].

When t = 2, you’ll probably recognize the result as the famous Mandelbrot set:

Creating movie files input 5

Creating movie files output 5

Different values of t give interesting visualizations of other sets:

Creating movie files input 6

Creating movie files output 6

You can animate this visualization by building up a set of frames, say from t = 2 to t = 4:

Animate this visualization by building up a set of frames

(That line takes a few minutes to run on my computer. You could make it faster by taking advantage of new C compilation techniques in Mathematica 8.)

Once you have the list of frames, a simple Export command suffices to create the movie:

Creating movie files input 8

Creating movie files output 8

Here is the resulting movie, uploaded to YouTube:

This movie was created using the QuickTime format, but you can also use others, such as AVI, GIF, or SWF.

Click here to download this post as a CDF.

If you have a question you’d like answered in this blog, you can submit it to the Q&A Team using this form. For daily bite-sized Mathematica tips, follow our @MathematicaTip Twitter feed.

Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.

6 comments

  1. Is this possible to do with sync sound?

    Reply
  2. Ok, so how would I make a video like your screen-casts? I mean one the shows the mouse pointer, use of scroll bars and has verbal discussion.

    Reply
  3. @Ted, if you use a mac, screenflow is the program that I use to make podcasts. Basically, it records what is on your screen – pointer movements, slides, movies that you are showing. It even records or mutes the voice input.

    Reply
  4. I second Barrett’s comment, can you add a Sound object to go with your video?
    Also, can you specify the frame rate?

    Reply
  5. Another tool that can be used to create screencasts is Snapz Pro X. I have used this quite often for Mathematica demos.

    Reply
  6. Any new developments regarding the sound issue?

    Reply