Skip to content

Instantly share code, notes, and snippets.

@superboum
Last active September 24, 2015 08:15
Show Gist options
  • Save superboum/8d3954cab2deaeafb2f1 to your computer and use it in GitHub Desktop.
Save superboum/8d3954cab2deaeafb2f1 to your computer and use it in GitHub Desktop.
Create an optimized gif from a video with ffmpeg
#!/usr/bin/env bash
ffmpeg -y -ss 0:02 -t 6 -i ./VID_20150816_151940.mp4 \
-vf fps=20,scale=400:-1:flags=lanczos,palettegen palette.png
ffmpeg -ss 0:02 -t 6 -i ./VID_20150816_151940.mp4 -i palette.png -filter_complex \
"fps=20,scale=400:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
# Other not so good possibilities
#
#ffmpeg -t 4 -ss 2:05 -i ./vid.mp4 output.gif
#gifsicle -Okeep-empty --resize-colors 64 --resize _x240 -o output-opt.gif output.gif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment