Skip to content

dummyx/rast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVT-AV1 Rust Bindings Workspace

This workspace provides a modern Rust binding for SVT-AV1 (validated against v4.0.1):

  • svt-av1-sys: Raw FFI bindings generated by bindgen at build time. Full API coverage for the encoder API in v4.0.1 (decoder optional; decoder headers are not vendored).
  • svt-av1: Thin, safe(ish) wrappers with RAII around core init/teardown and I/O calls for the encoder.

Getting started

  • Preferred, fully deterministic setup is to use the vendored headers (v4.0.1) in this repo. The build now compiles the vendored SVT-AV1 encoder via CMake when pkg-config is disabled (default) and no SVT_AV1_LIB_DIR is provided:
    • SVT_AV1_NO_PKG_CONFIG=1 SVT_AV1_INCLUDE_DIR=vendor/SVT-AV1/Source/API cargo check -p svt-av1-sys
    • SVT_AV1_NO_PKG_CONFIG=1 SVT_AV1_INCLUDE_DIR=vendor/SVT-AV1/Source/API cargo check -p svt-av1
  • Alternatively, ensure compatible SVT-AV1 headers and libraries are installed on your system (needed for decoding since the vendored copy is encoder-only).
    • Typical headers: EbSvtAv1Enc.h, EbSvtAv1Dec.h in /usr/include/svt-av1.
    • Libraries: libSvtAv1Enc.* and libSvtAv1Dec.* in your system library path.
  • Build now pins to the vendored headers by default; pkg-config is opt-in via SVT_AV1_NO_PKG_CONFIG=0 (or setting SVT_AV1_PKG_CONFIG_NAME).
    • If decoder is enabled, a decoder-capable install must be provided (vendored headers do not ship EbSvtAv1Dec.h).

Environment variables

  • SVT_AV1_INCLUDE_DIR: directory containing headers.
  • SVT_AV1_LIB_DIR: directory containing libraries.
  • SVT_AV1_PKG_CONFIG_NAME: override pkg-config package name.
  • SVT_AV1_NO_PKG_CONFIG=1: disable pkg-config probing (default if unset; pkg-config is opt-in).
  • SVT_AV1_BUILD_FROM_SOURCE=1: force building the vendored SVT-AV1 codec; set to 0 and provide libraries/pkg-config if you want to skip the vendored build.
  • SVT_AV1_ENABLE_LTO=0/1: toggle link-time optimization for vendored builds (default off; rust-lld cannot consume GCC LTO objects, so enable only if your toolchain supports it).

Features

  • encoder (default) and decoder features in both crates; the vendored SVT-AV1 v4.0.1 tree exposes encoder headers only. Enabling decoder requires an external SVT-AV1 install with decoder headers/libraries and SVT_AV1_NO_PKG_CONFIG=0 (or manual include/lib dirs).
  • svt-av1-sys/buildtime-bindgen enabled by default to run bindgen at build time.

Examples

  • Minimal encoder example (header-only bindgen during CI or local):
    • SVT_AV1_NO_PKG_CONFIG=1 SVT_AV1_INCLUDE_DIR=vendor/SVT-AV1/Source/API cargo check -p svt-av1 --example encode

Example (encoder)

use svt_av1::encoder::{Encoder, Configuration};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (mut enc, mut cfg) = Encoder::init_default()?;
    cfg.source_width = 1920;
    cfg.source_height = 1080;
    cfg.frame_rate_numerator = 30;
    cfg.frame_rate_denominator = 1;
    enc.set_parameter(&cfg)?;
    enc.init()?;
    // send pictures via BufferHeader and drain packets
    Ok(())
}

Notes

  • These crates mirror the C API closely to ensure stability and completeness.
  • The svt-av1 crate intentionally keeps abstractions minimal.

About

A Rust binding for SVT-AV1

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages