Micha1982
Posts: 261
Joined: Wed Oct 03, 2012 11:18 am

How to create animation?

Wed Nov 12, 2014 8:34 pm

Can someone tell me please, how to create a video with Mathematica?
An .avi in 1080i or 720p, with following code for example:

Code: Select all

r[t_] := {Sin[t] + 2 Sin[2*t], Cos[t] - 2 Cos[2*t], -Sin[3*t]};
T[t_] := 1/Norm[r'[t]]*r'[t];
U[t_] := 1/Norm[r''[t]]*r''[t];
V[t_] := Cross[T[t], U[t]];

W[a_, d_, t_] := r[t] + d*Cos[a]*U[t] + d*Sin[a]*V[t]

Manipulate[With[{d = .5, M = 124, Q = 124},
 Graphics3D[
  Table[
    GraphicsComplex[
     Flatten[Table[
      W[(a + s)*2 Pi/3, d, t + s*8*Pi/M],
     {t, {j*2 Pi/M, (j + 1) 2 Pi/M}}, {a, 0, 2, 1}], 1],
      Polygon[{{1, 2, 5, 4}, {2, 3, 6, 5}, {3, 1, 4, 6}}]],
  {j, 0, Q, 1}],
 Lighting -> "Neutral", Boxed -> False, ViewPoint -> Above, 
 ImageSize -> 600, PlotRange -> 3.5]],
{s, 0, 1}]
Or this

Code: Select all

WfPlot[ s_, t_] :=
 Graphics[
  Table[
   {AbsoluteThickness[1.5], 
    Line[
     Table[
      {i + If[Mod[i, 2] == 0, s*Sin[j*2 Pi/66 + i*2 Pi/6 + t], 0],
       (-1)^i*.5 + .4*j},
     {i, 1, 19}]]},
   {j, 1, 69, 1}],
  PlotRange -> {{1, 19}, {.8, 27.2}}, 
  ImageSize -> {500, 500}]

LogPolar[x_, y_] := {Log[Sqrt[x^2 + y^2]], ArcTan[x, y]}

Manipulate[
  ImageTransformation[
   WfPlot[s, t],
  LogPolar[#[[1]], #[[2]]] &, DataRange -> {{-Pi, Pi}, {-Pi, Pi}}],
{s, 0, 1}, {t, 0, 2Pi}]
Should be a simple infinite loop if ready, running ~30seconds for example.
Alles, was schiefgehen kann, wird auch schiefgehen.

szhorvat
Posts: 24
Joined: Wed Jun 04, 2014 2:07 am

Re: How to create animation?

Sat Feb 07, 2015 3:41 am

I would recommend exporting the frames one by one as PNG images, then encoding the video afterwards. Yes, Mathematica can export videos directly, but creating frames separately gives you more control and makes it easy to interrupt or resume the process.

I do this even on fast desktops, and I wouldn't consider any other methods on a computer as slow as the Raspberry Pi.

Micha1982
Posts: 261
Joined: Wed Oct 03, 2012 11:18 am

Re: How to create animation?

Thu Jun 04, 2015 7:55 pm

Now I am a bit more into it and playing around with ´Export´ - still trying with .avi, but
if I do with ´Animate´, my problem is that I see the controlpanel in the resulting output/video...is there maybe any easy way to disable the ´Control´bar and buttons completely in the output/export?

Export as pictures maybe can solve this, possibly a good idea, I did not tried it out for now - but it maybe would be critical for longer/fluid sequences - 25/fps for example will produce a large amount of pictures...

I will try it with pictures later, but has someone possibly an idea how to simply disable the complete panel with animate for example?
Alles, was schiefgehen kann, wird auch schiefgehen.

Micha1982
Posts: 261
Joined: Wed Oct 03, 2012 11:18 am

Re: How to create animation?

Thu Jul 09, 2015 2:56 am

Solved with

Code: Select all

...
Export[NotebookDirectory[] <> "... .avi", 
 Table[ (...function...) ], "FrameRate" -> 25, 
 "VideoEncoding" -> Uncompressed]
(hopefully that way works for my next tryouts, too :roll: )
Alles, was schiefgehen kann, wird auch schiefgehen.

Return to “Wolfram Language”

Who is online

Users browsing this forum: No registered users and 2 guests