Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using youtube-dl and gifify from the command-line to make a cat gif

Using youtube-dl and gifify from the command-line

Turn this cute YouTube cat video into a briefer-but-still-cute GIF:


Software to download

  • youtube-dl is a command-line tool for quickly downloading video files from a given YouTube URL
  • the gifify utility for converting video into GIFs, which is part of the gifsicle library.

Installing youtube-dl and gifify

Homebrew can be used to install both youtube-dl and gifify (via gifsicle):

brew install youtube-dl gifsicle

Commands to run

# downloads from the given YouTube URL to the file path of `catdrawer.mp4`
youtube-dl "" -o catdrawer.mp4

# creates a copy of `catdrawer.mp4` and converts seconds 19 to 27 to a GIF file named `catdrawer.gif`
gifify catdrawer.mp4 -o catdrawer.gif  --from 19 --to 27 --resize 400:-1 --colors 128

Then upload to Imgur. You could probably write a curl command to do it via Imgur's API

Piping youtube-dl to stdout

As victorperin points out below, instead of downloading and saving a MP4 file with youtube-dl, we can pipe the MP4 file to stdout and directly into gifify. This means that the intermediary catdrawer.mp4 is never saved to disk:

youtube-dl "" -o - \
   | gifify -o catdrawer.gif --from 19 --to 27 --resize 400:-1 --colors 128
Copy link

victorperin commented Jan 27, 2020

You can use pipes to run it faster, without need to write to disk when downloading the mp4 version:

youtube-dl "" -o - | gifify -o catdrawer.gif --from 19 --to 27 --resize 600:-1 --colors 128


Copy link

dannguyen commented Feb 6, 2020

good call! I frequently forget that - can be used to direct to stdout instead of a file path. I'll update my readme, thanks!


Copy link

weltonrodrigo commented Oct 8, 2020

Gifify is installed with brew install gifify


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