Created
March 30, 2025 05:31
-
-
Save z0u/0b751e1328981ab86b32b26711e683a4 to your computer and use it in GitHub Desktop.
Converts a video to a gif for embedding in README files.
This file contains hidden or 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
sudo apt update && sudo apt install ffmpeg gifsicle | |
# First pass: Generate a palette | |
ffmpeg -i input.mp4 -vf "fps=10,palettegen" palette.png | |
# Second pass: Create the GIF using the palette | |
ffmpeg -i input.mp4 -i palette.png -filter_complex "fps=10 [x]; [x][1:v] paletteuse" output.gif | |
# Third pass: Optimize the GIF | |
gifsicle -O3 --lossy=30 output.gif -o output-optimized.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment