A workflow for animated GIFs using Blender and GIMP

· by Chris · Read in about 4 min · (835 Words)

I made a GIF of a part of my screen to demonstrate the foot pivot switching in the PitchiPoy Blender animation rig. After all the cropping and skipping of frames, the final animated GIF is 1.5MB. The source .mkv file, with all the frames, and 1440p resolution, was 1.6MB! Whether this was an appropriate use of a GIF, given its size, I’m not sure. We’ll see if my web host ever complains. At the moment, sometimes a GIF is what we want, easy to embed and share, and now I have a workflow for it.

I had a screen recording generated with Vokoscreen (for which I downloaded a Mageia .rpm package, but I cannot seem to find it online at the moment). Initially I tried cropping it and cutting it in Kdenlive (using their Appimage, because the very outdated Mageia 5 rpm version was crashing on renders). This worked fine, but Kdenlive render profiles still have me a bit confused, especially when it comes to non-standard resolutions. It is probable that I could export the project as a GIF, based on this clue but I had an epiphany that saved me from having to figure out more about Kdenlive for now: I can just use Blender to edit the video and output the PNGs.

The workflow for this GIF turned out to be as follows:

  1. Take a video of the foot rig controls in action, using Vokoscreen. This was straightforward, once I’d decided which software to use and tested that it’s stable (two perennial problems in Linux: too many potential tools for the job; and too many of them turn out to be unstable on a given system).
  2. Edit the video in Blender, and save it as PNG images of the frames. Further detail below.
  3. Open the images in GIMP, and export them as an animated GIF. Further detail below.

Steps in Blender:

  1. Open a new file. Switch from the Default to the Video Editing screen layout.
  2. Change the upper left pane from Graph Editor to Properties. This will make it easy to adjust render settings, like resoluton, on the same screen.
  3. In the Video Sequence Editor (VSE) pane, Add a Movie. Choose the file that Vokoscreen saved.
  4. Cutting If all you want is to keep a subset of the frames in the original video, set the start and end frames in the Timeline editor (or at Properties Editor > Render > Dimensions > Frame Range). That’s it!*
  5. Cropping Even though I call this “cropping,” in fact we don’t need to use what Blender calls Image Crop to reduce the image area included in the GIF. Instead, while looking at the preview in the UV/Image Editor pane, adjust VSE > Properties Region > Image Offset and Properties Editor > Render (camera icon) > Dimensions > Render Resolution until the desired framing is achieved.
  6. Deciding a frame rate You can reduce the final file size by skipping frames. In this case the actual frame rate doesn’t matter since we’re outputting a pile of .png files and using GIMP to create the animation. Set Properties Editor > Render > Dimensions > Frame Range > Frame Step to 2 if you want to output only every second frame.
  7. Saving the video Check Sequencer under Post Processing in the Properties Editor to render the video from the Video Sequence Editor, not the camera in 3D view (Manual Reference). Choose PNG from the file format menu under Properties Editor > Render > Output. Now render the animation in one of several ways. The CTRL-F12 key combination is used by my window manager, so I use the Render Animation menu item under Render in the Info bar, or the Animation button in Properties Editor > Render > Render.

*If you need to do something fancy, cut the strip in the sequence editor by positioning the frame marker and hitting K. Delete unwanted bits with X. Move strips with the right mouse button (and G if wanted). Deliciously consistent with the other operations in Blender. Probably not intuitive to new users.

Now there should be a load of .png files in a directory (/tmp on my system). They’re named by frame number, so if you’ve rendered other files into the directory before, there can be extras that don’t belong (ask me why it’s at the top of my mind right now).

The next thing is to get GIMP to make these files into a GIF.

Steps in GIMP:

  1. Open as layers all the PNG files to be included in the GIF. Since they’re named by frame number, they’ll be loaded in the right order.
  2. Run Filters > Animation > Optimize (for GIF). I tried with and without this step, and using it reduced my file size from 8.2MB to 1.5MB.
  3. Export as and give the filename the extension .gif. Check the as animation box and set the delay to 1/(framerate) – e.g. if the framerate is 12fps, the delay is 1/12 of a second, or about 83ms. I also selected Loop forever.