Comment by Aldipower
9 days ago
AVIF consumes around 25 times more CPU during encoding as JPEG. Take this in consideration if you pay for the power consumption. And on the user-facing side, if you upload an images it takes f.ex. 12 seconds (sic!) and not half a second.
12 seconds? It takes 7 seconds on my phone, in a wasm runtime using an older version of the encoder.
From my experience throwing random JPEGs at it, it's 3 to 4 times smaller, that's a good chunk of data saved, which in turn is a lot of energy saved on visitors' radios being active.
Unlike with jpeg, you don't need 85 or 95 percent on the quality score, 50 is more than good enough for most pictures on a website.
If you're hosting images and want a fully lossless encoding the CPU time may become a factor, but if you're hosting user generated content, I don't think it's all that bad. Plus, you can just move the encoding part to the user side of the equation and pretend it's part of the upload progress bar if you're desperate to pay the power bill.
The numbers above coming from a test run on one of my own servers serving and receiving user generated images. It is a Intel E5 56 CPU threads machine with DDR4 RAM. A single thread may be slower then your phone CPU cores, but that's what you find very often when running servers.
I see, I can imagine a decade old CPU without any kind of video acceleration taking a while indeed. Technology has come a long way since the E5-2690v4.
Still, when encoding AVIF, there are various quality options to choose from, and the encoder has gotten better over the past year. On my i3-2120 NAS (which even your E5 should beat on single core perf), encoding an image at default speed takes about 4-6 seconds (JPEG about 2s), while producing an image of comparable quality a third the size. If I pass --speed 10, converting PNG to AVIF takes only half a second.
The standard AV1 encoder has improved a lot over a short amount of time, I invite you to run another benchmark, you may be surprised.
1 reply →
The assumption is that a file is read more than it is written. If you spend less time and power compressing the file, you will spend more time and power delivering the file, and often not save anything on the decompression side.
If you want to optimize the user-facing side, you might want to pick HEIC instead to optimize for commonly available HEVC/h.265 hardware encoding capabilities, or to be selective instead and pick AVIF when AV1 capabilities are present.
AVIF is notoriously CPU-intensive to compress without acceleration, but assuming you pay for storage and/or delivery, the results are impressive. JPEG-XL and HEIC also do very well. JPEG really shouldn't be used unless you're trying to target devices that can only read JPEG.
HEIC/h.265 is not supported on Windows 11 by default. You have to pay for an additional decoder that currently costs $0.99 in the Windows Store. Although SOME OEMs provide pre-installed h.265 decoders with hardware acceleration.
So don't do that, please.
Windows 11 is not an image viewer. Your applications that view images bundle the decoders they need.
For various reasons, AVIF and HEIF/HEIC support is generally bundled together in the same decoders. Both of CrabbyAVIF and libheif, for example, read both AVIF and HEIF/HEIC, so while HEIC might sometimes be supported without AVIF, it's harder to have support for AVIF with HEIF/HEIC.
Browsers are a bit weird, not sure why they haven't enabled support.
(It would be an entirely new thing for you to use hardware decoders for stills, so no reason to worry about it as something restrictive.)
1 reply →
It is irrelevant that an image gets read more then written, if the user needs to wait 120 seconds (2 minutes) when uploading 10 images, instead of waiting 6 seconds for all of those 10 by using simple jpeg.
Regarding HEIC, you know the browser acceptance for this, do you? https://caniuse.com/?search=heic
It is not only relevant, it is the sole justification for the existence of compression in the first place.
120 seconds is an arbitrary number to throw out there, AVIF compression time is purely dependent on how aggressive you want the file compressed. The ability to go completely nuts with computation is great for when you create the assets once for example.
Native browser support for HEIC is poor, yes. No idea why tbh, the underlying libraries generally support it. Heck, AVIF and HEIF/HEIC support is almost universally bundled together.
Take CrabbyAVIF and libheif: both provide both AVIF and HEIF/HEIC support. Android uses CrabbyAVIF as the platform AVIF/HEIF reader for reference, and considering that Google Photos natively supports HEIF/HEIC (even in browser). They're also using CrabbyAVIF in Chromium, but for some reason they disabled the HEIF/HEIC feature.
If you're making browser apps, you will ultimately care about storage and bandwidth, so AVIF or JPEG-XL are your main options. Outside browser apps you can pick entirely as you please, and if end-user encoder performance matters, HEIC ends up likely winning as hardware AV1 encoders are still less common.
This is also the reason JPEG2000 died off and became a niche format mainly for archival; it's extremely CPU-intensive.
You can adjust the speed of both, you don't have to use the default of whatever library versions you're using. My cjxl defaults to 2x more CPU than avifenc's default, but I can make it 30x more or 480x less; libaom certainly lets you waste a lot more CPU than libjxl, if that's what you want.
I don't know if anyone has published an encode time / quality comparison of the various encoders. It'd have to be recent to include this year's libaom image optimizations.