Skip to main content
100%

Screen Recording to GIF

✓ Published0🌍 Public
Mmbostock
Last edited Jun 1, 2017
Created on Dec 20, 2014

This example shows how to convert a screen recording into an animated GIF using command-line tools. It first generates a color palette from the video with FFmpeg’s `palettegen` filter, then applies that palette with `paletteuse` to produce a high-quality GIF. The workflow also supports optional frame dropping via `fps` and cropping through FFmpeg’s `crop` filter. The code relies solely on FFmpeg and Gifsicle, with QuickTime Player used for the initial recording.

AI-generated description

If you haven’t already:

brew install ffmpeg gifsicle

Open QuickTime Player. File > New Screen Recording. Record. Trim as needed. Save as foo.mov.

First compute a good color palette:

ffmpeg -i foo.mov -vf 'scale=-1:-1:flags=lanczos,palettegen' foo-palette.png

Then make your GIF:

ffmpeg -i foo.mov -i foo-palette.png -filter_complex 'scale=-1:-1:flags=lanczos[x];[x][1:v]paletteuse' foo.gif

To drop frames, add fps=10, to the -filter_complex argument.

To crop, add crop=width:height:x:y, to the -filter_complex argument.

See also https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality.

gpl-3.0 Licensed

Similar vizzes