惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
D
Docker
IT之家
IT之家
博客园_首页
罗磊的独立博客
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
美团技术团队
Y
Y Combinator Blog
博客园 - 聂微东
量子位
阮一峰的网络日志
阮一峰的网络日志
GbyAI
GbyAI
Microsoft Security Blog
Microsoft Security Blog
博客园 - Franky
Martin Fowler
Martin Fowler
Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
月光博客
月光博客
G
Google Developers Blog
B
Blog
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
AVIF encoding speed — the numbers nobody talks about
Serhii Kalyn · 2026-05-15 · via DEV Community

Everyone talks about how small AVIF files are.

Almost nobody talks about what it costs to generate them in production.

I run a free image converter built on Rust + libvips. After processing thousands of conversions, here are the numbers that changed how I think about format choice.


The compression story you already know

AVIF beats WebP on file size. For photos and gradients:

  • AVIF saves ~50% vs JPEG (median across 600 photos)
  • WebP saves ~31% vs JPEG
  • At the same DSSIM score, AVIF produces files ~50% smaller than WebP

Real and impressive. But that's only half the equation.


The encoding cost nobody talks about

Here's what actually happens when you encode with libaom (the default AVIF encoder):

Format Encoding time (1080p) Peak CPU Peak RAM
WebP ~90ms ~20% ~200MB
AVIF (libaom, default settings) 1–4 seconds ~400% (4 cores) ~2.5GB
AVIF (maximum quality) up to 48 seconds - -

In my tests, AVIF encoding with libaom was up to 47× slower than WebP at comparable quality settings. Peak memory usage during a single 4000px AVIF conversion reached ~2.5GB in Sharp/libvips using libaom. WebP used ~200MB for the same image.

The memory usage surprised me most. For a service handling concurrent batch uploads, that's not a benchmark number - it's a capacity planning problem.

AVIF optimizes bandwidth. WebP optimizes compute.


The effort parameter an oversimplification

If you use Sharp, you've probably assumed: higher effort = smaller files.

In practice, it's not that simple.

quality is the primary driver of file size. effort controls how much time the encoder spends searching for better compression decisions. Depending on the image, higher effort can slightly reduce or even increase output size. The effect is unpredictable and usually marginal.

This is documented behavior in Sharp's issue tracker (#3418): at fixed quality, increasing effort sometimes produces larger files.

Practical starting point for AVIF in Sharp:

sharp(input).avif({ quality: 72, effort: 5 }).toBuffer()

Enter fullscreen mode Exit fullscreen mode

effort: 5-6 hits a reasonable balance. Going to effort: 9 adds seconds of encoding for marginal and unpredictable gains.


When to use which format

Scenario Best format
User uploads processed on-the-fly WebP
Static assets, pre-generated at build AVIF
Real-time transforms WebP
Maximum compression for photos AVIF
Low-memory servers WebP
Screenshots, UI, flat graphics WebP
Photography, gradients, textures AVIF

The rule I follow: AVIF for static, WebP for dynamic.

A 4-second encoding time is fine in a CI pipeline. It's not fine when a user is waiting for their converted file.


What this looks like in a converter pipeline

In my converter pipeline, the challenge with AVIF isn't throughput it's memory spikes under concurrent load. If multiple users upload large images simultaneously, AVIF jobs can spike memory hard across all cores.

Current approach:

  • Concurrency limits on AVIF jobs
  • Default effort: 4 for interactive conversions fast enough for real-time use
  • SVT-AV1 encoder is worth watching: roughly 2× faster than libaom, 5× faster than rav1e at comparable quality

Browser support

Effectively solved:

  • WebP: ~95.6% global support (Safari 14+, all modern browsers)
  • AVIF: ~94.3% global support (Safari 16.4+, Chrome 85+, Firefox 93+)

The standard fallback pattern still makes sense:

<picture>
  <source srcset="image.avif" type="image/avif">
  <source srcset="image.webp" type="image/webp">
  <img src="image.jpg" alt="...">
</picture>

Enter fullscreen mode Exit fullscreen mode


The actual takeaway

"Better compression" and "better for your use case" aren't the same thing.

AVIF is technically superior for compression. But if you're encoding on-the-fly, the encoding overhead is a real operational cost not a benchmark footnote.

WebP is fast, lightweight, and produces files dramatically smaller than JPEG. It's not a consolation prize.

The best setup: pre-generate AVIF for static assets, encode WebP dynamically, serve both via <picture> or CDN content negotiation.


Building Convertify a free image converter powered by Rust + libvips. Week 9 of building in public.

Sources: Sharp GitHub issues #2597, #3418 · libheif AVIF Encoder Benchmark · SpeedVitals WebP vs AVIF · W3Techs image format statistics (May 2026) · Can I Use