Convert a video clip to a Gif file


I recently run into a problem that I would like to convert a video clip to a gif file cause I did the screen recording from my laptop, but the file size is too large (> 100MB) to upload to my blog. So, a reasonable solution is probably to shrink the size either by trimming the video or translating the video file to another format; for example, a possible format to upload is a gif file.

Here I would show you how to do it. It’s pretty simple. Thanks, @Alex Dergachev’s gist.

Steps 1 - to capture the screen recording

press Shift-Command (⌘)-5 on your keyboard to see all the controls you need to record video and capture still images of your screen.


You can choose to record the entire screen or selected portion.

  1. Record the entire screen macos-mojave-screenshot-menu-fullscreen-record-inline-icon.png

  2. Record a selected portion of the screen macos-mojave-screenshot-menu-selection-record-inline-icon.png

Step 2 - Installation for necessary packages

  1. brew install FFmpeg
  2. Go to, download, and install.
  3. brew install gifsicle

Step 3 - Command

ffmpeg -i -s 640x480 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out_file_path.gif

Notes on the arguments:
-r 10 tells FFmpeg to reduce the frame rate from 25 fps to 10
-s 600x400 tells FFmpeg the max-width and max-height
--delay=3 tells gifsicle to delay 30ms between each gif
--optimize=3 requests that gifsicle use the slowest/most file-size optimization

And now, here it goes.

After that, you can find the Gif file and start using it.Enjoy.