11 unstable releases (3 breaking)

Uses new Rust 2024

0.4.2 Apr 6, 2026
0.4.1 Feb 26, 2026
0.3.0 Jan 10, 2026
0.2.5 Oct 23, 2025
0.1.4 Jul 23, 2022

#11 in Video

Download history 539909/week @ 2026-02-21 628928/week @ 2026-02-28 760787/week @ 2026-03-07 707481/week @ 2026-03-14 640316/week @ 2026-03-21 647236/week @ 2026-03-28 647251/week @ 2026-04-04 670359/week @ 2026-04-11 638885/week @ 2026-04-18 705554/week @ 2026-04-25 718505/week @ 2026-05-02 769338/week @ 2026-05-09 902657/week @ 2026-05-16 872433/week @ 2026-05-23 914927/week @ 2026-05-30 810607/week @ 2026-06-06

3,630,101 downloads per month
Used in 319 crates (5 directly)

BSD-2-Clause

140KB
3K SLoC

av1-grain

docs.rs Crates.io LICENSE

This crate contains helper functions for parsing and generating AV1 film grain data.

This code was originally created for use in rav1e. It has been moved to this crate so it can be shared with other AV1 crates that need to deal with film grain.

Examples

The generate_photon_noise_params and write_grain_table APIs live behind the create feature. Enable it in your project to produce plain-text photon noise tables compatible with svt-av1, aomenc, and similar encoders:

use av1_grain::{
    generate_photon_noise_params, write_grain_table, NoiseGenArgs, TransferFunction,
};

fn main() -> anyhow::Result<()> {
    // This would apply to the entire video--we can use `u64::MAX` as the end timestamp for simplicity.
    let segment = generate_photon_noise_params(
        0,
        u64::MAX,
        NoiseGenArgs {
            // This setting can range from 100-6400 to adjust the noise strength
            iso_setting: 800,
            width: 1920,
            height: 1080,
            transfer_function: TransferFunction::BT1886,
            chroma_grain: true,
            random_seed: None,
        },
    );

    write_grain_table("example.tbl", &[segment])?;
    Ok(())
}

Running this program generates a photon noise table covering the entire video (start_time 0 to end_time u64::MAX) and stores it in example.tbl. The file extension is arbitrary; .tbl is a common choice.

Dependencies

~0.2–0.8MB
~15K SLoC