Thursday, November 10, 2016

Android screen capture with GIF format

GIF format is still here, and it's a handy way to make small videos. It's very easy to do despite of all ads telling us to buy their commercial software, and I'm going to describe the tools we need.

First, we need to capture the video of the screen. For Android, you can use ADV Screen Recorder, but surely there are tools for any platform. Please verify the recorder settings (you may want to disable mic recording and change the output folder to be on an external SD).

Second, after we recorded the video, we need to convert it into GIF-format. For that we're going to use FFMpeg tool (on Mac, just use "brew install ffmpeg").

GIF uses 256 colors, so we need to create an auxiliary palette file. Therefore, the converting process takes two steps: 1) create a palette, 2) use a palette and an input file to create the output GIF. The commands for that:

$ ffmpeg -i input.mp4 -vf fps=10,scale=320:-1:flags=lanczos,palettegen palette.png
$ ffmpeg  -i input.mp4 -i palette.png -filter_complex "fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif

output.gif is the resulting file. It's possible you may need to modify ffmpeg settings, but in most cases it's not needed. Have fun!