使用ffmpeg转换为gif的视频有一个框模式背景 [英] videos converted to gif with ffmpeg have a box pattern background

查看:648
本文介绍了使用ffmpeg转换为gif的视频有一个框模式背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用ffmpeg将我制作的小视频转换成GIF。但是,我注意到我所做的所有GIF都有某种模式背景。视频和gif之间的差异并不明显,但您可以在视频预览和gif预览之间明显区分:

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:

YouTube上的原始视频

gif in imgur album,以及gif和视频的缩略图

我发送到ffmpeg转换的命令:

The command I send to ffmpeg to convert:

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

我已经试过了,没有-pix_fmt rgb24。任何想法可能是什么?

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

推荐答案

调色板过滤器在这里工作,因为palettegen过滤器应用 Frankie Sierra dithering v2Lite默认情况下

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

请注意,FFmpeg的GIF编码器不支持RGB24。更好地选择 pal8 ,因为调色板仅限于256种颜色。

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

这篇关于使用ffmpeg转换为gif的视频有一个框模式背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆