Notes & TILs
Search…
Converting videos to High quality GIFs
Posted on Dec 6, 2020
Converting videos to GIFs using ffmpeg is a pain in the ass if you don't know what's happening. GIF size getting 10x the size of original video ? Don't worry, I got you!
  1. 1.
    Always create a custom palette
  2. 2.
    Don't increase/decrease file dimensions
  3. 3.
    Save unnecessary frame conversion by using -t to convert video until a timestamp.
  4. 4.
    Experiment with fps (default value is 24)
1
# Get video dimensions
2
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 video.mp4
3
# generate a palette
4
ffmpeg -i video.mp4 -vf "fps=22,scale=1024:-1:flags=lanczos,palettegen" palette.png
5
# use the generated palette
6
ffmpeg -t 29 -i video.mp4 -i palette.png -filter_complex "fps=22,scale=1024:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
Copied!
Download complete script here​

Resources

Last modified 19d ago
Copy link
Contents
Resources