zenavif-serialize
AVIF container serializer (muxer) in pure Rust. Creates MPEG/HEIF/MIAF/ISO-BMFF boxes for still images, animations, and grid layouts. Only dependency is arrayvec.
Together with zenrav1e, it enables pure-Rust AVIF encoding.
Fork of avif-serialize
Forked from avif-serialize v0.8.8 by Kornel Lesinski. Rebased on upstream as of 2026-02-14.
Changes from upstream (+2,188 lines, -55 lines):
- Animation —
AnimatedImagebuilder with per-frame durations, keyframe control, alpha track (animated.rs, 795 lines) - Grid/tiled images —
GridImagebuilder for tile-based encoding up to 256x256 (grid.rs, 695 lines) - Transforms — rotation (irot), mirror (imir), clean aperture crop (clap), pixel aspect ratio (pasp)
- Metadata — ICC profile, EXIF, and XMP embedding as separate items with item references
- Builder API —
Aviffybuilder with#[non_exhaustive]types for forward compatibility
Original still-image serialization code is largely unchanged.
Features
- Still images with optional alpha channel (separate monochrome AV1 plane)
- Animated AVIF with per-frame durations and keyframe control
- Grid/tiled images (up to 256x256 tiles) for large images
- HDR metadata — content light level (clli) and mastering display color volume (mdcv)
- Transforms — rotation, mirror, clean aperture crop, pixel aspect ratio
- Color spaces — full CICP support (BT.709, BT.2020, Display P3, PQ, HLG, etc.)
- ICC profiles, EXIF, and XMP metadata embedding
- 8/10/12-bit depth
no_stdcompatible (withalloc)
Usage
Add to Cargo.toml:
[]
= "0.1"
Still image (minimal)
Compress your pixels with an AV1 encoder first, then wrap the bitstream:
let avif_bytes = serialize_to_vec;
Still image (configured)
use ;
let avif_bytes = new
.set_color_primaries
.set_transfer_characteristics
.set_content_light_level
.set_rotation // 90 degrees CCW
.to_vec;
Animation
use ;
let mut anim = new;
anim.set_timescale; // milliseconds
anim.set_color_config;
let frames = vec!;
let avif_bytes = anim.serialize;
Grid (tiled)
use GridImage;
let mut grid = new;
grid.set_color_config;
let avif_bytes = grid.serialize?;
Compatibility
Output is tested against three independent AVIF parsers: avif-parse, zenavif-parse, and mp4parse (Mozilla). Browser compatibility has not been independently verified.
License
BSD-3-Clause. Original code copyright Cloudflare, Inc. Fork additions copyright Imazen LLC.