Skip to content

Instantly share code, notes, and snippets.

@heyitsaamir
Last active April 5, 2024 16:57
Show Gist options
  • Save heyitsaamir/3a2162cda051da8d9a858d4b521f7c88 to your computer and use it in GitHub Desktop.
Save heyitsaamir/3a2162cda051da8d9a858d4b521f7c88 to your computer and use it in GitHub Desktop.
Convert .mov files to gifs for easier PR integration

Convert To gif

If you're on a mac, and you use cmd+shift+5 to record screens to put in your PR, here's a little snippet i wrote to convert that into a gif:

convertToGif () {
  if [ -z "$1" ]; then
    mov_filename=$(ls -t ~/Desktop/*.mov | head -n 1)
    if [ -z "$mov_filename" ]; then
      echo "No MOV files found on the desktop."
      return 1
    fi
  else
    mov_filename="$1"
  fi

  gif_filename="${mov_filename%.*}.gif"
  ffmpeg -i "$mov_filename" -pix_fmt rgb8 -r 10 "$gif_filename" && gifsicle -O3 "$gif_filename" -o "$gif_filename"
}

If you provide it a filepath it'll use that (convertToGif <your_recording.mov>), otherwise if you just say convertToGif, then it'll pick the latest .mov file from your desktop. Put that in your ~/.zshrc or ~/.bashrc file. You'll need to download ffmpeg which actually does the conversion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment