Skip to content

Latest commit

 

History

History
109 lines (69 loc) · 4.45 KB

convert-video-to-gif.md

File metadata and controls

109 lines (69 loc) · 4.45 KB

Convert Video to GIF

Sometimes you need to convert a video like a screen recording to a high-quality GIF file. This is the tool to do that on macOS.

It is particularly useful when you want to add a screen recording to your Pull Request or issue while the platform only allows images like Bitbucket. It uses the best settings to keep the GIF file size as small as possible since some platforms have a very low size limit for image files. It also maintains a good quality while reducing the framerate.

You can check a demo GIF there.

Getting started

The tool uses ffmpeg to extract the video frames and ImageMagick to convert the frames to a GIF file.

brew install ffmpeg imagemagick

# if you are using macOS silicon
arch -arm64 brew install ffmpeg imagemagick

Installation

This tool is available as an Apple shortcut - recommended option.
Alternatively, as Apple Automator Workflow, if Shortcut won't work on your Mac for some reason.
You can also opt in to use this tool directly from script.

Apple Shortcut

This is a recommended way of installing this tool on your Mac – as an Apple shortcut. You can install it from the link below:

https://www.icloud.com/shortcuts/db18892750f3453c83d57281915be17f

Then you will be able to convert a video to a GIF file from the context menu on the Finder app, as shown in Figure below.

expand to see the figure

convert a video from the context menu


After the installation of the Apple Shortcut, you can check how to use it via script (and skip the following Apple Automator Workflow section).

Apple Automator Workflow

This is an alternative way of installing this tool on your Mac - as an Automator Workflow. It requires more setup to do, but it could be a fallback installation process if Apple Shortcuts is not available on your Mac (i.e. unsupported version). You can import it to your Automator from the /assets/Convert Video to GIF.workflow directory in this repo as Quick Actions.

expand to see the instructions

Instructions how to import the workflow

  1. Download the .workflow directory:
  2. Move the Workflow to the Services Folder:
    To access this directory, they can:
    • Open Finder.
    • Press Command + Shift + G and type ~/Library/Services/.
  3. Enable the Quick Action:
    • Go to System Preferences > Extensions > Finder Extensions or Services.
    • Ensure the new workflow is enabled in the list
      Finder extension

4. Use the Quick Action:

  • The workflow will now be available in the Finder’s right-click Quick Actions menu for any compatible files.

Then you will be able to convert a video to a GIF file from the context menu on the Finder app.

expand to see the Quick Action context menu figure

convert a video from the context menu


As mentioned earlier, you can opt in to use this tool via script bellow.

Script

You can also run the script directly:

curl -fsSL https://raw.githubusercontent.com/friedrit/productivity/master/convert-video-to-gif.sh | zsh -s -- <video-2-convert.mov>

Or you just download it, place it somewhere like ~/bin/, make it executable chmod +x ~/bin/convert-video-to-gif.sh and then you can run it from CLI:

~/bin/convert-video-to-gif.sh <video-2-convert.mov>

Having that script locally gives you an ability to modify the conversation key parameters inside the script.


Below are additional instructions of using locally parametrised script via Quick Actions if installed via Automator Workflow.
If you'd like to use the advantages of using a local script for the contextual menu from the Finder, you'd need to update the workflow in Automator

As indicated on the figure:

Atomator Workflow