3 ms·
When converting video to gif, I always use palettegen, e.g. ffmpeg -i input.mp4 -filter_complex "fps=15,scale=640:-2:flags=lanczos,split[a][b];[a]palettege
by dllu 10mo ago
When converting video to gif, I always use palettegen, e.g.
ffmpeg -i input.mp4 -filter_complex "fps=15,scale=640:-2:flags=lanczos,split[a][b];[a]palettegen=reserve_transparent=off[p];[b][p]paletteuse=dither=sierra2_4a" -loop 0 output.gif
See also: this blog post from 10 years ago [1]
[1] https://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html https://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
- CrossVR 10mo agoI've been thinking of integrating pngquant as an ffmpeg filter, it would make it possible to generate even better pallettes. That would get ffmpeg on par with gifski.
- xattt 10mo agoThose command flags just roll off the tongue like two old friends catching up! /s
- deleted 10mo ago[deleted]
- crazysim 10mo agoGifski (https://gif.ski/ https://gif.ski/) might be a good alternative to look to that's gif-pallete aware.
- dspillett 10mo agoDoes ffmpeg's gif processing support palette-per-frame yet? Last time I compared them (years ago, maybe not long after that blog post), this was a key benefit of gifski allowing it to get better results for the same filesize in many cases (not all, particularly small images, as the total size of the palette information can be significant).
- foltik 10mo agoIt’s a shame this isn’t the default.
- BoingBoomTschak 10mo agoI use `split[s0][s1];[s0]palettegen=max_colors=64[p];[s1][p]paletteuse=dither=bayer` personally, limiting the number of colors is a great way to transparently (to a certain point, try with different values) improve compression, as is bayer (ordered) dithering which is almost mandatory to not explode output filesizes.
- dceddia 10mo agoIn many cases today “gif” is a misnomer anyway and mp4 is a better choice. Not always, not everywhere supports actual video. But one case I see often: If you’re making a website with an animated gif that’s actually a .gif file, try it as an mp4 - smaller, smoother, proper colors, can still autoplay fine.