30 July 2017

MOV to GIF

For some of the workflows I put out here, animated gif images or videos illustrate them best. Here is a screencast showing member end-release conversions from STAAD to USFOS. Having never made gifs before, I began in earnest.

On Mac

  1. Launch QuickTime Player and record screen using ^⌘N.
  2. Use its basic editing tools like Show Clips (⌘E) and Split Clip (⌘Y) options to cut out non-moving frames to reduce the clip’s overall duration, so file size can be optimised.
  3. Export to a suitable progressive video mode, say 720p or 480p, and save the resulting .mov file.

To convert the thus generated .mov file into a .gif file, there are two options:

  1. Faster, which results in a smaller file size, with dithered quality (hat-tip: @dergachev):

    ffmpeg -i fltr1.mp4 -vf "scale=min(iw\,500):-1" -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=7 --colors 128 > mail.gif
    
  2. An improved quality, which results in a larger file size (save the following into a gifenc.sh file, hat-tip: pkh.me):

    #!/bin/sh
    palette="/tmp/palette.png"
    filters="fps=15,scale=500:-1:flags=lanczos"
    ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
    ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2%
    

On Windows

Windows has no built-in tool to record screen, and one requires a tool like VLC. See step-wise instructions by Windows Club to perform this. But, this captures the entire desktop, and there’s no option to select target area. So, I had to import this into an iMovie, and crop it to keep only the target area and clips of interest. See an example.