Skip to content

Instantly share code, notes, and snippets.

@z0u
Created March 30, 2025 05:31
Show Gist options
  • Save z0u/0b751e1328981ab86b32b26711e683a4 to your computer and use it in GitHub Desktop.
Save z0u/0b751e1328981ab86b32b26711e683a4 to your computer and use it in GitHub Desktop.
Converts a video to a gif for embedding in README files.
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