Turn this cute YouTube cat video into a briefer-but-still-cute GIF:
- 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.
Homebrew can be used to install both youtube-dl and gifify (via gifsicle):
brew install youtube-dl gifsicle
# downloads from the given YouTube URL to the file path of `catdrawer.mp4`
youtube-dl "https://youtu.be/sP1_rT0wyQo" -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
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 "https://youtu.be/sP1_rT0wyQo" -o - \
| gifify -o catdrawer.gif --from 19 --to 27 --resize 400:-1 --colors 128
You can use pipes to run it faster, without need to write to disk when downloading the mp4 version: