Convert video to animated gif
# Simple conversion to animated gif. ffmpeg -hide_banner -nostdin -y -i VIDEO.mkv OUTPUT.gif # Conversion to animated gif using palette colors. # 1 - Export the palette colors. ffmpeg -y -i VIDEO.mkv -vf fps=10,palettegen palette.png # 2 - Output the GIF using the palette. ffmpeg -y -i VIDEO.mkv -i palette.png -filter_complex "fps=10" OUTPUT.gif # If you want higher quality, use the followings: ffmpeg -y -i VIDEO.mkv \ -vf fps=10,scale=0:-1:flags=lanczos,palettegen palette.png ffmpeg -y -i VIDEO.mkv -i palette.png -filter_complex \ "fps=10,scale=0:-1:flags=lanczos[x];[x][1:v]paletteuse" OUTPUT.gif
Note: The resulting animated GIF file size will inherently be bigger than the original video. See https://stackoverflow.com/questions/12573604/gif-created-from-a-movie-file-with-ffmpeg-is-really-large-in-size.
Example
Reference
- http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html