Skip to content

Instantly share code, notes, and snippets.

@saiday
Last active July 29, 2019 06:57
Show Gist options
  • Save saiday/60b4917b74d7a77d9106406d2ee85f2f to your computer and use it in GitHub Desktop.
Save saiday/60b4917b74d7a77d9106406d2ee85f2f to your computer and use it in GitHub Desktop.
convert mp4 video to gif
# dependencies:
# - ffmpeg
# - imagemagick
# Usage:
mkdir mp4_to_gif
ffmpeg -i myfile.mp4 -vf scale=1024:-1:flags=lanczos,fps=10 mp4_to_gif/ffout%03d.png
convert -loop 0 mp4_to_gif/ffout*.png output.gif
rm -rf mp4_to_gif
# CLI shorthand:
# video to gif
alias v2g='function _v2g(){ mkdir mp4_to_gif && ffmpeg -i $1 -vf scale=420:-1:flags=lanczos,fps=10 mp4_to_gif/ffout%03d.png && echo "converting gif ..." && convert -loop 0 mp4_to_gif/ffout*.png output.gif && rm -rf mp4_to_gif };_v2g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment