AVIF bindings for Python with NumPy support
Project description
pyavif
AVIF bindings for Python with NumPy support.
Installation
pip install numpy
pip install .
Basic Usage
Decoding
from pyavif import Decoder, DecoderCodec
# Create decoder with default codec (DAV1D - fastest decoder)
decoder = Decoder()
decoder.init("image.avif", decoder_threads=1)
image = decoder.get_image(0) # Returns numpy array (H, W, C)
# Or specify a different codec
decoder = Decoder()
decoder.init("image.avif", decoder_threads=1, codec=DecoderCodec.AOM)
Encoding
import numpy as np
from pyavif import Encoder, EncoderOptions, EncoderCodec
# Create encoder
opts = EncoderOptions()
# Use alternative codec
opts.codec = EncoderCodec.RAV1E
encoder = Encoder("output.avif", width=256, height=256, channels=3, depth=8, options=opts)
# Add frame and finish
image = np.zeros((256, 256, 3), dtype=np.uint8)
encoder.add_frame(image)
# finish when done
encoder.finish()
Advanced
Batch Encoding
from pyavif import BatchEncoder, EncoderOptions
opts = EncoderOptions()
output_paths = ["out1.avif", "out2.avif", "out3.avif"]
batch_encoder = BatchEncoder(output_paths, opts)
# Add frames for all files at once
frames = [image1, image2, image3] # Same-length list as output_paths
batch_encoder.add_image_batch(frames, duration=1)
batch_encoder.finish_all()
Encoder Options
from pyavif import EncoderOptions, EncoderCodec
opts = EncoderOptions()
opts.codec = EncoderCodec.RAV1E # RAV1E, AOM (default: AOM)
opts.quality = 85 # 0-100 (default: 80)
opts.speed = 6 # 0-10, higher = faster (default: AVIF_SPEED_DEFAULT)
opts.quality_alpha = 100 # Alpha channel quality (default: AVIF_QUALITY_LOSSLESS)
opts.timescale = 30 # Animation timescale in fps (default: 30)
opts.max_threads = 4 # Thread count (default: 1)
Building libavif
We ship prebuilt static libavif artifacts in lib/ to keep installs simple. If you
need to rebuild them, use the scripts below. They clone libavif at v1.3.0, build
static libraries with RAV1E, DAV1D, AOM, and libyuv, and refresh headers in
lib/include/avif.
- Linux (manylinux_2_28, glibc 2.28+):
bash scripts/build_libavif_linux.sh(Docker required) - macOS:
bash scripts/build_libavif_macos.sh(requires CMake, Rust, nasm, meson, ninja) - Windows:
pwsh scripts/build_libavif_windows.ps1(requires CMake, Rust, NASM, Perl, Meson/Ninja)
Set LIBAVIF_VERSION to override the libavif tag.
CI Wheels
GitHub Actions builds wheels via cibuildwheel using .github/workflows/build_wheels.yml.
Trigger the workflow manually or on a version tag (for example v0.0.1).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyavif-0.0.1-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: pyavif-0.0.1-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 6.6 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
718d76090fd9e04873ea711ed2839121d7f422c97ca1239d7e1246f67ffa8a70
|
|
| MD5 |
5835d7b2131882436a800ebe8ea27b82
|
|
| BLAKE2b-256 |
4adcbe6a0aa16450be43a3bada7b2242ea9e035a74d995a033368cd3474cbb29
|
Provenance
The following attestation bundles were made for pyavif-0.0.1-cp39-abi3-win_amd64.whl:
Publisher:
build.yml on gracia-labs/pyavif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyavif-0.0.1-cp39-abi3-win_amd64.whl -
Subject digest:
718d76090fd9e04873ea711ed2839121d7f422c97ca1239d7e1246f67ffa8a70 - Sigstore transparency entry: 870263470
- Sigstore integration time:
-
Permalink:
gracia-labs/pyavif@e62d66552f3851f6405826b8477638a4a04ecee8 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/gracia-labs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@e62d66552f3851f6405826b8477638a4a04ecee8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyavif-0.0.1-cp39-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyavif-0.0.1-cp39-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08a1d3cf7dc5fdb6142880862cbc51831613b1bd586c590079be68a2e484c18b
|
|
| MD5 |
fdec17efea5f45a552a8caa3e6839343
|
|
| BLAKE2b-256 |
8f24e7248ab4924c6f1f4948d8bd55549d4bcd701843af8635a391a30d7479a5
|
Provenance
The following attestation bundles were made for pyavif-0.0.1-cp39-abi3-manylinux_2_28_x86_64.whl:
Publisher:
build.yml on gracia-labs/pyavif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyavif-0.0.1-cp39-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
08a1d3cf7dc5fdb6142880862cbc51831613b1bd586c590079be68a2e484c18b - Sigstore transparency entry: 870263478
- Sigstore integration time:
-
Permalink:
gracia-labs/pyavif@e62d66552f3851f6405826b8477638a4a04ecee8 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/gracia-labs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@e62d66552f3851f6405826b8477638a4a04ecee8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyavif-0.0.1-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyavif-0.0.1-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74463b2229b1a48698e5e65cd32d9e18e44473b99fa62af4b4e299316493b410
|
|
| MD5 |
bb0c1f03be3b21ed37b46d14bfaaa994
|
|
| BLAKE2b-256 |
0260ed448980eb2919c583b2bccee6bd6fcbff73cb1cb5afa14a8c8f0ceb8bd3
|
Provenance
The following attestation bundles were made for pyavif-0.0.1-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
build.yml on gracia-labs/pyavif
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyavif-0.0.1-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
74463b2229b1a48698e5e65cd32d9e18e44473b99fa62af4b4e299316493b410 - Sigstore transparency entry: 870263489
- Sigstore integration time:
-
Permalink:
gracia-labs/pyavif@e62d66552f3851f6405826b8477638a4a04ecee8 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/gracia-labs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@e62d66552f3851f6405826b8477638a4a04ecee8 -
Trigger Event:
push
-
Statement type: