FFmpeg now supports JPEG XL and AVIF: how to convert images
This is an update to the previous post Best FFmpeg commands
Full support available since FFmpeg v5.1 LTS.
These libraries should be compiled and installed:
Then FFmpeg should be compiled with options
--enable-libaom. Yeah, we need
libaom 'cause AVIFF is part of AV1, the open video format.
Convert to JPEG XL
$ ffmpeg -i image.png -c:v libjxl image.jxl
Distance: Butteraugli distance, lower is better, 0.0 - lossless, 15.0 - minimum quality.
Effort: higher is better, 7 is the best quality, 1 - the worst.
Convert to AVIF
- Convert PNG to AVIF:
$ ffmpeg -i image.png -c:v libaom-av1 -still-picture 1 image.avif
- Convert PNG to animated AVIF image:
ffmpeg -i video.mp4 animated.avif
More encoding options are available:
-b 700k -tile-columns 600 -tile-rows 800 - example for the bitrate and tales.
Where these formats can be used?
CanIuse says AVIF can be used in Chrome 85, Firefox 93 and Opera 81 and later. Currently, not supported in MS Edge and IE(and will never be). For mobile platforms, you need the newer browsers - Chrome 103 and Safari 16 and later.
For JPEG XL current situation is tragic: no support on mobile platforms yet, the same for desktop, but can be enabled with special flag: