Saturday, December 30, 2017

Convert Large GIFs to Video


For GIFs under 100 MB, there are plenty of free tools around like Convertio that will convert GIF animations to AVI, MPEG, etc. But I'm not talking about HD reaction memes here. I'm helping to process full on NOAA AWIPS radar graphics. The following example is 2015 x 1224 px, and 300 frames long. These GIFs range from 97 to 170 MB, so the free online tools aren't going to cut it right now.

I'll do this manually with:
  • GIMP: A free, open source alternative to Photoshop
  • A GIMP plugin called Export Layers
  • Sony Vegas, or any other video editing platform - even Windows Movie Maker

Download & Install the Plugin

  • Download and install GIMP
  • Download the Export Layers plugin (zipped)
  • Copy the export_layers folder and the export_layers.py Python script file to your home directory:

    My Plug-Ins directory is: C:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins but you may need to do some sleuthing depending on your installation, version, etc. If so:
    •  Go to Edit > Preferences
    • Expand the Folders group
    • Select the Plug-Ins preferences to view the Plug-Ins folder locations
    • Copy the folder listed along with your software installation location
  • Open GIMP (or restart GIMP) and check the File menu for the new Export Layers options

Open a GIF in GIMP

File > Open will load a GIF frame by frame as separate layers, in descending order. The first frame of the animation will be at the bottom, and the last frame will be located up at the top. Conveniently, the layers are automatically named with a frame position, and a frame duration in parentheses. These are helpful in case any frames (especially the first or last frames) are longer than the rest of the frames in the animation.

Export Layers

Now that the Export Layers plug-in is installed, you can immediately export the loaded GIF layers as individual frames.
  • Create a new directory to organize these frames separately since it'll only be a temporary intermediate set of files
  • Back in gimp choose File > Export Layers
  • Now simply choose the new directory that was just created to store these exports. Accept all default settings, and click Export Layers then Export to process the exports

Load Frames in Video Editing Software

  • Open your preferred video editing software
  • Find the preferences section that handles the default duration of still frames. Set this value to match the general frame rate of the GIF. In the screenshot above, most frames are 50 ms, while only the first and last frame of the animation hang a bit longer to denote the beginning and ending of the radar loop.

    In Sony Vegas:
    • Options > Preferences
    • Editing tab
    • Set New still image length (seconds) to 0.05 seconds (50 ms)
    In Windows Movie Maker:
    • Load all individual frames
    • Select all frames (Ctrl+A)
    • Navigate to the Edit tab
    • Set the Duration to 0.05 seconds
  • In Vegas, now Import the frames which will have the duration set by default
  • Next, select the first frame and expand it or manually set the Duration value for that individual frame to match the duration listed in its file name. In this example, the first frame hangs for 700 ms (0.7 seconds)
  • Repeat this step for the last frame in the animation: 1500 ms (1.5 seconds)

Export

  • Export and share as you need