I've the following code:

ManToGif[man_, name_String, step_Integer] := 
  Export[name <> ".gif", 
   Import[Export[FileNameJoin[{NotebookDirectory[], "hoi2.avi"}], 
      man], "ImageList"][[1 ;; -1 ;; step]]];
hoi2 = Manipulate[Ud = x; Uin = 5; Rb = 10; c = 150*10^(-6);
  y[fin_] = 
   2*fin*(2*T*Ud - ((Ud)/(fin)) + ((Uin*Sin[2*Pi*fin*T])/(2*Pi*fin)) +
       c*Rb*(2*Ud - Uin)*(Exp[-((T)/(c*Rb))] - 1));
  Teqn[fin_] = 
   Abs[Uin*Sin[2*Pi*fin*T - (Pi/2)]] - 2*Ud == (Uin - 2*Ud)*
  Tsol[fin_?NumericQ] := 
   FindRoot[Teqn[fin], {T, 1/(4*fin), 1/(2*fin)}]; 
    Table[{fin, y[fin] /. Tsol[fin]}, {fin, 0.001, 1000, 0.01}]], 
   ListPlot[{{1000, 3.0214}, {500, 2.8021}, {250, 2.4941}, {125, 
      2.1516}, {62.5, 1.9251}, {0.01, 1.7622}}, 
    PlotStyle -> Red]], {x, 0, 1}]; ManToGif[hoi2, 
 FileNameJoin[{NotebookDirectory[], "hoi2"}], 1];

It creates two files, a .avi file and a .gif file. When I open the .gif file I get a black screen (so nothing is shown). What is the reason for that behaviour? What do you get when you run this code?

  • $\begingroup$ A Manipulate expression is a piece of code, not a sequence of images. Export has no automatic conversion from that code to images. $\endgroup$ – m_goldberg Jun 20 '18 at 1:13
  • 5
    $\begingroup$ @m_goldberg it actually does. Manipulate is smart enough to chunk itself and make a .gif file. Never made an AVI from one though $\endgroup$ – b3m2a1 Jun 20 '18 at 1:57
  • $\begingroup$ @b3m2a1. I am surprised. I admit I never tried to use Export that way. Thanks for putting me straight. $\endgroup$ – m_goldberg Jun 20 '18 at 2:22
  • $\begingroup$ @m_goldberg I was surprised too when I first saw it. I'd hazard that anything that has an Animator as part of its box structure can do that, too. $\endgroup$ – b3m2a1 Jun 20 '18 at 2:27
  • 1
    $\begingroup$ Related: mathematica.stackexchange.com/questions/4229/… $\endgroup$ – Michael E2 Jun 20 '18 at 3:28

As of 11.1 Manipulate exports to GIF; In 11.2 Manipulate will also export to animated PNG. AVI doesn't support Manipulate just yet, but Manipulate and Table have a very similar syntax, for now one could simply change Manipulate to Table to generate a list of images and export as normal.



Sorry I missed the last part of the question. I tried the code above, the Manipulate has a really hard time Dynamically updating and it mostly blows up with General::munfl: Exp[-166667.] is too small to represent as a normalized machine number; precision may be lost.

Since I can't get the Manipulate to work on its own, this is probably why your gifs are failing. The result of Table was however able to export to both formats.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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