Skip to main content

Contrast Aware Multiscale Banding Index (CAMBI) as a VapourSynth plugin.

Project description

vapoursynth-cambi

Contrast Aware Multiscale Banding Index (CAMBI) as a VapourSynth plugin. This is a pure Rust+VapourSynth implementation of Netflix's banding detection algorithm without a dependency on libvmaf.

Install

Via vsrepo:

vsrepo install cambi

Or manually on Windows: download a release from the Releases page and unzip cambi.dll into a plugins directory. There are separate artifacts for Raptor Lake (*-raptorlake.zip) and AMD Zen 4 (*-znver4.zip) CPUs which may or may not have better performance than the plain x86_64 build.

API

cambi.Cambi(
    clip: vs.VideoNode,
    window_size: int = 65,
    topk: float = 0.6,
    tvi_threshold: float = 0.019,
    max_log_contrast: int = 2,
    eotf: int = 0,
    prop: str = "CAMBI",
) -> vs.VideoNode

Calculates the CAMBI score of each frame of clip and stores it in the frame property named prop.

  • clip — Constant format 10-bit integer clip.
  • window_size — Window size to compute CAMBI. Note that libvmaf's documented default is 63 but internally it actually uses 65, so this plugin defaults to 65 as well.
  • topk — Ratio of pixels for the spatial pooling computation.
  • tvi_threshold — Visibility threshold for luminance ΔL < tvi_threshold*L_mean for BT.1886.
  • max_log_contrast — Maximum contrast in log luma level (2^max_log_contrast) at 10-bit. Default 2 is equivalent to 4 luma levels at 10-bit.
  • eotf — Electro-optical transfer function.
    Value Description
    0 Determine from the _Transfer frame property.
    1 ITU-R BT.1886.
    2 Perceptual quantizer (SMPTE ST 2084).
  • prop — Name of the frame property to store the CAMBI score in.

Benchmark

With warm caches, this plugin is about 2.7 times faster than akarin.Cambi() on 1080p clips (222.3 fps vs. 80.5 fps over 10 runs of 1001 frames each).

from vstools import core, initialize_clip, set_output, vs

core.set_affinity(16)

src = core.bs.VideoSource(r"/path/to/1080p_video.m2ts")
src = initialize_clip(src, bits=10)

set_output(core.cambi.Cambi(src, window_size=65))
set_output(core.akarin.Cambi(src, window_size=65))
$ hyperfine --warmup 1 'vspipe test.py --end 1000 -o {output_node} .' -P output_node 0 1
Benchmark 1: vspipe test.py --end 1000 -o 0 .
  Time (mean ± σ):      4.502 s ±  0.043 s    [User: 53.877 s, System: 4.763 s]
  Range (min  max):    4.450 s   4.575 s    10 runs

Benchmark 2: vspipe test.py --end 1000 -o 1 .
  Time (mean ± σ):     12.435 s ±  0.080 s    [User: 183.298 s, System: 2.283 s]
  Range (min  max):   12.342 s  12.570 s    10 runs

Summary
  vspipe test.py --end 1000 -o 0 . ran
    2.76 ± 0.03 times faster than vspipe test.py --end 1000 -o 1 .

Build

Rust v1.93.0-nightly and cargo may be used to build the project. Older versions will likely work fine but they aren't explicitly supported.

$ git clone https://github.com/sgt0/vapoursynth-cambi.git
$ cd vapoursynth-cambi

# Debug build.
$ cargo build

# Release (optimized) build.
$ cargo build --release

# Release build optimized for the host CPU.
$ RUSTFLAGS="-C target-cpu=native" cargo build --release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vapoursynth_cambi-1.2.0.tar.gz (27.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vapoursynth_cambi-1.2.0-py3-none-win_amd64.whl (241.4 kB view details)

Uploaded Python 3Windows x86-64

vapoursynth_cambi-1.2.0-py3-none-manylinux_2_28_x86_64.whl (553.8 kB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

vapoursynth_cambi-1.2.0-py3-none-manylinux_2_28_aarch64.whl (184.7 kB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

vapoursynth_cambi-1.2.0-py3-none-macosx_13_0_arm64.whl (170.0 kB view details)

Uploaded Python 3macOS 13.0+ ARM64

File details

Details for the file vapoursynth_cambi-1.2.0.tar.gz.

File metadata

  • Download URL: vapoursynth_cambi-1.2.0.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for vapoursynth_cambi-1.2.0.tar.gz
Algorithm Hash digest
SHA256 2fd327bdd7a1a8d3ccb896c1ddd7ae7f779edf1df96d718c91b0d7cd99415886
MD5 0674db481a983392152a1785e46e79aa
BLAKE2b-256 96abbe19cb5310c80c2c12945f915d585b9b44e72ac489afa3c5e8a1e39ed645

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cambi-1.2.0.tar.gz:

Publisher: publish.yml on sgt0/vapoursynth-cambi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cambi-1.2.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for vapoursynth_cambi-1.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 3367479ab11c8243f9b741190264dafb98175211b462cc915e1f16b8d070aa48
MD5 c82cec5985c3de7f232d99f043724380
BLAKE2b-256 c201a9f2f1f3abde90ed75d6e2181f400af0a4bb3cf4748d7908f3153e1298fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cambi-1.2.0-py3-none-win_amd64.whl:

Publisher: publish.yml on sgt0/vapoursynth-cambi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cambi-1.2.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vapoursynth_cambi-1.2.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b26cca436ce7dfbe8df272b5e4185a72301ce1d9341879953c24e935aa4ebabe
MD5 5c9b69186c93827f643e9dd26a85ff8e
BLAKE2b-256 cd783dd6ed73d1756aea02675a776f180b170aa44c9bc45b8a7ac3331aa3f8f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cambi-1.2.0-py3-none-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on sgt0/vapoursynth-cambi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cambi-1.2.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vapoursynth_cambi-1.2.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7a1362b2d87222241b45f0b708bc16685e1043e00406658b09ee128a7af9d548
MD5 2029aef625f54d10196f3b3182db684e
BLAKE2b-256 b666c0a15d6887f797dd42917892993e6ed412d9529004779320fcb117c23654

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cambi-1.2.0-py3-none-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on sgt0/vapoursynth-cambi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cambi-1.2.0-py3-none-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for vapoursynth_cambi-1.2.0-py3-none-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 c2f659a6eceea288c5d003f8f8119887495cac834fca790970112ca3bfaf4081
MD5 53f6d6363170d23e33257ffcec7b6711
BLAKE2b-256 63f3c56b8ed8cca9f247bf572e2c590e78b7ea1d8b386fcd68da852357847731

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cambi-1.2.0-py3-none-macosx_13_0_arm64.whl:

Publisher: publish.yml on sgt0/vapoursynth-cambi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page