# Exporting a Manipulate expression to .avi and .gif

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)*
Exp[-T/(c*Rb)];
Tsol[fin_?NumericQ] :=
FindRoot[Teqn[fin], {T, 1/(4*fin), 1/(2*fin)}];
Show[ListPlot[
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?

• A Manipulate expression is a piece of code, not a sequence of images. Export has no automatic conversion from that code to images. – m_goldberg Jun 20 '18 at 1:13
• @m_goldberg it actually does. Manipulate is smart enough to chunk itself and make a .gif file. Never made an AVI from one though – b3m2a1 Jun 20 '18 at 1:57
• @b3m2a1. I am surprised. I admit I never tried to use Export that way. Thanks for putting me straight. – m_goldberg Jun 20 '18 at 2:22
• @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. – b3m2a1 Jun 20 '18 at 2:27
• – Michael E2 Jun 20 '18 at 3:28

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.