Possible Duplicate:
Is it possible to prerender animation in Wolfram Mathematica?
Does Mathematica support variable frame rate for any video format, in analogue of GIF-style “DisplayDurations”?

I would like to make a movie that shows a series of Plot/ListPlot outputs as frames for s seconds of time each. Is there a simple way to do this?


2 Answers 2


When you have 50 frames already computed with Plot

expr = (1 - a) Exp[-x^2] + .5 a D[Exp[-x^2], x, x];
frames = Table[Plot[expr, {x, -2, 2}, PlotRange -> {Automatic, {-1, 1}}, 
  Filling -> Bottom], {a, 0, 1, 1/49}];

what you can do when exporting e.g. "AVI" files is setting the "FrameRate". When you want to have for instance every frame displayed for 1 second the frame rate is 1 frame/second too. Unfortunately, this does only work for integer values and to have an image displayed for s seconds, you would have to set frame rate to 1/s. One bad hack is to set the frame rate to 1 and use several copies of the same frame. A better option here might be to use external tools. See for instance the link Jens gave in the comments

A different thing is, when you use animated "GIF" files. There you can set the "Duration" of every frame which can be larger than one second and smaller too.

Export["movie.gif", frames, "DisplayDurations" -> 1]

enter image description here

  • $\begingroup$ You've got a typo: it's FrameDurations, not FrameDuration. Without the s at the end, your exported movie doesn't actually have the duration you specified, but instead uses the default. $\endgroup$
    – Jens
    Jan 11, 2013 at 6:49
  • $\begingroup$ @Jens Thanks, I corrected my type (without using your Typo ;-) and now it works as expected. $\endgroup$
    – halirutan
    Jan 11, 2013 at 7:33
  • $\begingroup$ Wow, it this a type of typo explosion? $\endgroup$
    – Jens
    Jan 11, 2013 at 7:36

I might as well add another answer based on the variable frame rate GIF player contained in this answer:

exportMovie[movieName_String, list_, delayList_: {.03}] := 
 Module[{l = Length[list],
   delays = Abs@Flatten[{delayList}],
  delta = Min[delays];
  times = Round[PadRight[delays, l, delays]/delta];
  frames = 
   Flatten@Table[Table[list[[i]], {times[[i]]}], {i, Length[times]}];
  Export[movieName, frames, "FrameRate" -> Round[1/delta]]

This takes a list of frames, e.g. the ones in halirutan's answer, and exports them as a movie in AVI or MOV or similar formats. These formats recognize the "FrameRate" option in Export, and you can calculate the desired frame rate as the reciprocal of the frame duration in seconds.

In this function, I generalized this to a variable frame rate by allowing an optional third argument that contains a list of individual frame durations. If the list is shorter than the number of frames, it's repeated. To make certain frames in the list of the first argument appear longer, I simply replicate them a number of times depending on how much longer than the minimum duration in the list of the third argument is.

So with the example

expr = (1 - a) Exp[-x^2] + .5 a D[Exp[-x^2], x, x];
frames = Table[
   Plot[expr, {x, -2, 2}, PlotRange -> {Automatic, {-1, 1}}, 
    Filling -> Bottom], {a, 0, 1, 1/49}];

you would simply do

exportMovie["a.mov", frames, {.12}]

to get a movie where all frames have an approximate duration of .12 seconds (there is rounding error).

The export format above is determined simply by the file name extension, so you could replace .mov by .avi.


Not the answer you're looking for? Browse other questions tagged or ask your own question.