Message Boards Message Boards

0
|
3212 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Export Animation?

Posted 8 years ago
Animate[Plot[{Sin[x*Cos[a]]}, {x, -2.5*Pi, 2.5*Pi}, 
          PlotRange -> {{-2.5*Pi, 2.5*Pi}, {-2, 2}}, Axes -> {False}, 
          AspectRatio -> Automatic, 
          PlotStyle -> {Directive[Thickness[.03], Black]}], {a, -Pi, 0}, 
         RefreshRate -> 60, AnimationDirection -> ForwardBackward, 
         DefaultDuration -> 4]

So I've got this. What I really, really want to do but cannot figure out for the life of me is to export this animation as a .avi file with the following specifications:

  1. Just export the plot itself (not the moving bar for "a" or the either of the boxes around the plot
  2. Export with a minimum height of 1920 pixels
  3. Export with a minimum width of whatever corresponds to the height with the same aspect ratio
  4. Export is 4 seconds long, from a=-Pi to a=0
  5. Export is 60fps
  6. Export has an alpha channel so that the white background is transparent and only the black animated plot shows up.

I know that this is a tall order. I've looked at countless tutorials and I'm completely lost. I'm on Mathematica 10.3. If somebody could just please give me one template example that meets these specifications for this specific animation (shown above) that I could use for all my other endeavors, I would be forever indebted.

POSTED BY: John Travolski
2 Replies
Posted 8 years ago

I apologize for the late response, but it worked beautifully. Thank you so much for this. Also, I appreciate your suggestion as well.

POSTED BY: John Travolski

Note that this is not very fast, and very memory hungry (240*2 MP images).

imgs = Table[
   Rasterize[
    Plot[{Sin[x Cos[a]]}, {x, -2.5 Pi, 2.5 Pi}, 
     PlotRange -> {{-2.5 Pi, 2.5 Pi}, {-2, 2}}, Axes -> {False}, 
     AspectRatio -> 1/4, ImageSize -> {1920, 1000}, 
     PlotStyle -> {Directive[Thickness[.03], Black, 
        JoinForm["Round"]]}], "Image", 
    RasterSize -> {1920, 1000}], {a, Subdivide[-\[Pi], 0, 240 - 1]}];
Export["out.avi", imgs, "FrameRate" -> 60]

Alpha channel is not possible as far as I know. But any editing software will be able to easily key out the white!

A better way (generally) is to export separate image files, and load these into your favorite video editing software, it will be much faster, smaller video-files, and saving separate image files is way less memory hungry... (the output file was 1.38 GB on my machine!!).

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract