Commands for converting images or videos to AVIF/AVIFS。
Here is a avif animated AVIF. Only 700kb. It should playing well on Chromium.
Why AVIF? Because it has same size as JPEG but higher quality. Also AVIF supports animated pictures (the file extesnion is avif
or avifs
). The qaulity is better than GIF and the size is smaller than webp.
It is easy to convert jpeg, png, gif or whatever to avif with these commmand line tools!
1. Tools used
OS:Arch Linux
All tools below are open-source and cross-platform. On Arch Linux they can be installed with pacman
.
Name | Description | Link |
---|---|---|
libavif | AVIF library | Github |
rav1e | AV1 encoder | Github |
aom | AV1 encoder | Google git |
imagemagick | Image processing tool | Official |
ffmpeg | Encoding tool | Official |
gpac | Encoding tool | Github |
av1an | Encoding tool | Github |
2. Convert GIF to AVIF
Convert GIF to yuv and pass it to avifenc to transcode to avif.
|
|
3. Convert JPEF/PNG to AVIF
Convet jpeg to avif:
|
|
Convet png to avif:
|
|
Batch convert png to avif:
|
|
4. Convert WebP to AVIF
After converting, the size is almost the same so it is a little bit meaningless.
|
|
5. Convert WebP (animated) to AVIF
There is no tool for directly convery animated webp to avif.
- Extract frames from webp:
|
|
- Create a mp4 file from extracted images and use libxaom for encoding.
|
|
- Convert mp4 file to avif:
|
|
6. Convert MP4/WebM videos to animated AVIF
- Make sure the video coding format is AV1. If not, convert the coding format to av1 codec with av1an (increase
--cq-lelve
for a smaller video):
|
|
- Convert mkv to mp4 and delete audio tracks
|
|
- Convert mp4 file to avif:
|
|
7. Convert AVIF to JPEG/PNG
AVIF to JPEG:
|
|
AVIF to PNG:
|
|