FrameRate option for Manipulate [duplicate]

This question already has an answer here:

Changing the speed of exported AVI videos

3 answers

I’m using the following code

Export[“”, Manipulate[Plot[Sin[2*Pi*k*x], {x, -1, 1},
PlotRange -> {{0, 1}, {-1, 1}}], {k, 0, 600, 0.001}], “FrameRate” -> 30]

to produce 600 plots of a sine function. If I set the FrameRate option to 30, I should have 600 frames at the rate of 30 frames per second, which gives me 20 seconds of animation time. Instead, I’m getting about 4 seconds and what is more, the animation runs twice (first time forward, and second time backwards).

How do I fix both of these problems?



1 Answer


The documentation for AutorunSequencing says “Each variable always starts from the initial value specified for it, and returns to the same value,” and doesn’t give any indication that this behavior can be changed. So unless you absolutely want that slider in your animation, then exporting the results from Manipulate isn’t a good way to make a movie file.

Create a list of images, here it has 600 images,

plotlist =
Table[Plot[Sin[2*Pi*k*x], {x, -1, 1},
PlotRange -> {{0, 1}, {-1, 1}}, PlotPoints -> 100], {k, 0, 6,

Then you can export the animation directly from Mathematica, using

Export[“out.avi”, plotlist, “Duration” -> 10, “FrameRate” -> 30]

(I’m using linux so I can’t export a .mov file)

This creates a 20-second video file (why it is double the value given for duration, I don’t know) that is 225MB.

A better option is to export frames and combine them into a movie using a better program.

Export[“frame_” <> IntegerString[n, 10, 4] <> “.png”,
, {n, Length@plotlist}];
Run[“! ffmpeg -framerate 30 -i frame_%04d.png -c:v libx264 -r 30 -pix_fmt yuv420p”]

The resulting animation file is also 20 seconds, and is only 280kB