如何有效压缩gif以减小大小? [英] How to compress gif effectively to reduce size?

查看:111
本文介绍了如何有效压缩gif以减小大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在博客中广泛使用gif.我们曾经在其中嵌入男高音纳米gifs(保持高宽比为90px,用于GIF预览和在移动设备上共享).现在,我们要创建自己的gif,并使用以下命令将mp4转换为gif,同时保持男高音nano gif的属性.使用ffmpeg版本4.1.4

We use gifs for our blog extensively. We used to embed tenor nano gifs(90px height maintaining aspect ratio, used for GIF previews and shares on mobile) in it. Now we wanted to create our own gifs and are using the following command to convert mp4 to gif while maintaining the properties of tenor's nano gif. using ffmpeg version 4.1.4

但是,我们发现创建的gif和使用次中音创建的gif在大小上存在巨大差异.

But we observed a huge difference in size between the gif we created and the one created using tenor.

ffmpeg -i input.mp4 -filter_complex"[0:v] fps = 10,scale = -1:90:flags = lanczos,分割[a] [b]; [a]调色板生成[p]; [b] [p] Paletteuse"-y output.gif

[原始MP4]-845KB

[Original MP4] - 845KB

Tenor Nano gif -42KB

ffmpeg gif -106KB

我们甚至尝试更改抖动算法以进一步减小尺寸,但最终却增加了噪音并损坏了gif品质

We even tried changing dithering algorithm to further reduce size but it ended up adding noise and damaged the gif quality

paletteuse = dither = bayer:bayer_scale = 5:diff_mode = rectangle

我们也尝试过在Gificle中调整颜色量化,但这没有用.

We tried tweaking colour quantization in gifsicle as well but it was of no use.

gifsicle --resize _x90 --colors 256 --color-method Diversity -dither = ordered --resize-method sample input.gif>output.gif

推荐答案

对我有用的是为输出gif指定较低的帧速率(-r 10).如果您追求高质量,可能不是您想要的,但是如果您追求高质量,那么可能会妥协.

What worked for me was specifying a lower frame rate (-r 10) for the output gif. Probably not what you want if you're after quality but if you're after quality file size may be the compromise.

这篇关于如何有效压缩gif以减小大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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