20

If a picture's worth a thousand words, then an animated GIF or video must surely be a great way to explain or illustrate a problem or solution, and sometimes it's the best way. Since people sometimes ask how to make these, I thought a question and a variety of answers would be useful.

In an earlier question I suggested that we ask for the ability to embed videos into posts. This is because it adds little to the size of the post, reducing the downloading burden on browsers, but allows a single click or inline viewing. (See this question on Gaming for how it would work. However, this facility hasn't been enabled for the main Mathematica SE site. I think it should be added (feature request tag...:)).

I suppose you should downvote this question if you would prefer to see fewer or no animations, regardless of how useful they might be.

I'm assuming that community votes (and edits) will indicate whether there are too many gratuitous animations in questions or answers!

13

LICEcap (Windows and Mac OS X) - animated GIF

LICEcap is a free utility that creates animated GIFs. Launch it, and place the frame over the area you want to record. You should probably resize the window better than I've done for this screen grab:

screencap of LICEcap

and press Record to start saving to a file:

choose a file

The Maximum Frames Per Second setting seems to be OK at 8 - making for smaller files, I suppose.

  • 4
    No animated GIFs were made during the making of this answer, strangely enough... – cormullion Jul 18 '13 at 12:18
4

QuickTime (Mac OS X) and Mathematica - animated GIF

Using the built-in QuickTime application, you can make screen recordings and then use Mathematica to convert them to animated GIFs.

  1. Make the recording. Launch QuickTime Player, choose File>New Screen Recording, and make your recording (and keep it short!). Save the file somewhere as a .mov file.

  2. Use Mathematica to convert the .mov file.

This is the sort of code you might use:

m = Import["...Untitled.mov", "ImageList"];
Export["/tmp/animated.gif", m]

You might be tempted to skip some frames of the recording, to reduce the size and keep the excitement up:

Export["/tmp/animated.gif", m[[1 ;; -1 ;; 3]]]

The problem with this method is that the movies often end up being too large. Apart from the obvious problems of annoying other users, I think there might be a size limit for uploaded images, but I can't find a reference for it.

You might be tempted to modify the images (in m) by running image processing functions to resize or otherwise modify every image. This can take some time if you've recorded more than a couple of seconds of action.

  • This is exactly what I've done, including resizing and skipping frames. – Michael E2 Jul 19 '13 at 0:39
4

Windows

ScreenToGif is something I found Codeplex.

List of features and gif examples are on Codeplex. For convenience, I've copy/pasted the ScreenToGif feature list below:

Features:

  • Record your screen and save directly to a gif looped animation.
  • Pause and continue to record.
  • Move the window around to record what you want.
  • You can add Text, Subtitles and Title Frames.
  • Edit the frames, add filters, revert, make yoyo style, change frame delay, add border, add progress bars.
  • Export frames.
  • Crop and Resize.
  • You can work even while the program is recording.
  • Remove frames that you don't want.
  • Select a folder to save the file automatically or select one before enconding.
  • Add the system cursor to your recording.
  • Very small sized, portable and multilanguage executable.
  • Start/Pause and stop your recording using your F keys.
  • Multi language: Portuguese, Spanish, Romanian, Russian, Swedish, Greek, French, Simplified Chinese, Italian, Vietnamese and Tamil.
  • GreenScreen unchanged pixels to save kilobytes.
  • You can apply actions/filters to selected frames.
  • Fullscreen Recording.
  • Snapshot Mode.
  • Drag and Drop to add frames in the editor.
3

To further automize cormullion's QuickTime solution, we can use Automator:

automator

Where ~/Desktop/movtogif.m is the path to this .m-script:

n=$ScriptCommandLine[[2]];
If[
FileExtension[n]=="mov",
Export[FileNameDrop[n]<>"/"<>FileBaseName[n]<>".gif",Import[n,"ImageList"]]
]

Now, all you have to do is save the movie from QuickTime and put it in the specified directory and a .gif will be automatically generated and saved in the same folder.

It's handy because now we don't have to rewrite the code every time, or even use our brains. Just drag and drop.

3

Linux - animated GIF

You're spoilt for choice if you use Linux. Rather than list all the possibilities here, refer to this answer on the AskUbuntu Stack Exchange.

Byzanz (Gnome only):

Here is a Mathematica function working with byzanz.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .