videos converted to gif with ffmpeg have a box pat

2019-09-15 02:17发布

I recently started using ffmpeg to convert small videos I make into gifs. However, I'm noticing that all gifs I make have a pattern background of some kind. It's not too noticeable of a difference between the video and the gif, but you can see it clearly in the difference between the video preview and the gif preview:

Original video on youtube

Gif in imgur album, along with a thumbnail of the gif and the video

The command I send to ffmpeg to convert:

ffmpeg -i "video path" -pix_fmt rgb24 "output file path"

I've tried it with and without the -pix_fmt rgb24. Any ideas what else it could be?

1条回答
贼婆χ
2楼-- · 2019-09-15 03:16

The palette filters work here, as the palettegen filter applies Frankie Sierra dithering v2 "Lite" by default.

ffmpeg -i in.mp4 -lavfi [0]split[a][b];[a]palettegen[p];[b]fifo[v];[v][p]paletteuse out.gif

Note that FFmpeg's GIF encoder does not support RGB24. Better to choose pal8 since the palette is limited to 256 colors.

ffmpeg -i in.mp4 -lavfi [0]split[a][b];[a]palettegen[p];[b]fifo[v];[v][p]paletteuse,format=pal8 out.gif
查看更多
登录 后发表回答