-
-
Save Om4ar/4f0aa9207779839f0a8dda899ee97081 to your computer and use it in GitHub Desktop.
Convert GIF using ffmpeg and ImageMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use ffmpeg to decode input video (GIF in this case) | |
ffmpeg -i input.gif decode/%d.png | |
# Use ImageMagick to crop, format: (W)x(H)+(W_SFHIT)+(H_SHIFT) | |
# Note the {from..to..skip} usage of Bash | |
convert decoded/{1..759..5}.png -crop 315x172+20+40 resized/%d.png | |
# An resize option | |
# convert decoded/{1..759..5}.png -crop 315x172+20+40 -resize 30% resized/%d.png | |
# (Optional) Tune brightness/saturation/contrase | |
# convert decode/{1..759..5}.png -modulate 200,150 -contrast-stretch 1% converted/%d.png | |
# Generate GIF. delay=10 if for browser, loop=0 means infinite. | |
convert -delay 10 -loop 0 resized/{1..151..3}.png output.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment