现代网络的动画 AVIF
Animated AVIF for the Modern Web

原始链接: https://arthur.pizza/2025/12/animated-avif-for-the-modern-web/

## 动画 AVIF:GIF 的替代品 作者推崇动画 AVIF 文件作为 GIF 的更优替代方案,理由是 AVIF 针对现代网络进行了更好的优化。虽然 GIF 具有其魅力,但 AVIF 动画提供了一种更高效的格式。 使用 FFMPEG 可以创建动画 AVIF。该过程涉及将视频源(或现有的 GIF)转换为 Y4M 中间文件,然后使用 `libsvtav1` 编解码器将其编码为 AVIF。关键的 FFMPEG 命令调整帧率(例如 `fps=15`)和缩放视频尺寸(例如 `scale=720:-1`)以进行优化。 值得注意的是,作者在 2025 年 12 月在 Debian 13 上直接编码为 AVIF 时遇到了问题,需要 Y4M 暂存步骤才能成功转换。他们希望未来不再需要此解决方法。本质上,AVIF 动画为循环视觉效果提供了一条有希望的途径,具有改进的性能。

一个黑客新闻的讨论强调了 **AVIF** 作为现代网络图像格式的潜力,特别是用于**带有透明度的动画图像**。 一位用户指出,AVIF 的完全 Alpha 层支持允许在所有主流浏览器中以合理的文件大小实现动画 *和* 透明度——这是对之前使用 WebM 和 Apple ProRes 解决方案的显著改进。 对话还涉及了 **WebP**,它也支持动画和透明度。 进一步的讨论扩展到 **视频编码**,质疑 AVIF 是否适合直播,并寻求最佳整体视频编码器的建议。 最后,该主题探讨了“基于文本的视频”(例如终端屏幕录制)的高效格式,直接文本更改是理想选择,而 AVIF 可以作为一种潜在的替代方案。
相关文章

原文

My Chirstmas gift to you

I think there’s something awesome about an image that can be animated. It’s different than a video clip because of the quick, loopy, and automatic nature of the format. GIFs have are a bit long in the tooth these days, and are not quite as optimized as should be for the modern web. The good news is, AVIF has an animation mode and it’s a much better solution than GIF.

To make an animated avif file, it seems be doable in FFMPEG!

Now that we have a needed applications we can build the clip. You can always clip out a peice of video with Kdenlive or FFMPEG, I simply grabbed an animated GIF that I had on my machine, but the process is mostly the same.

ffmpeg -i INPUT_VIDEO.webm -pix_fmt yuv420p -an -y output.y4m

You might want to limit the size and framerate

ffmpeg -i INPUT_VIDEO.webm -vf "fps=15,scale=720:-1" -pix_fmt yuv420p -an -y output.y4m

Now we need to encode the video into an avif

ffmpeg -y -i output.y4m -c:v libsvtav1 -crf 30 -b:v 0 -an -y output.avif

You might be able to get away running the command once, but for whatever reason in December of 2025, on Debian 13, it seems to have issues, unless you stage it to a y4m first.

ffmpeg -i INPUT_VIDEO.webm -vf "fps=15,scale=720:-1" -pix_fmt yuv420p -c:v libsvtav1 -crf 30 -b:v 0 -an -y output.avif

Let’s hope that works in the future.

联系我们 contact @ memedata.com