Crates.io | libvmaf-rs |
lib.rs | libvmaf-rs |
version | 0.5.2 |
source | src |
created_at | 2022-12-14 04:53:14.127073 |
updated_at | 2024-05-04 01:58:21.165326 |
description | (WIP) Ergonomic bindings for Netflix's libvmaf |
homepage | |
repository | https://github.com/ThatNerdUKnow/libvmaf-rs |
max_upload_size | |
id | 736349 |
size | 557,322 |
libvmaf-rs intends to be an ergonomic wrapper around the raw library bindings for Netflix's libvmaf
from libvmaf-sys
.
VMAF is an Emmy-winning perceptual video quality assessment algorithm developed by Netflix. It is a full-reference metric, meaning that it is calculated on pairs of reference/distorted pictures
First, construct Video
s from video files for both your reference and distorted(compressed) video files.
This example uses the same file for both reference
and distorted
, but normally distorted would be a compressed video while reference would point to the original, uncompressed video
let reference: Video = Video::new(&"./video/Big Buck Bunny 720P.m4v", 1920, 1080).unwrap();
let distorted: Video = Video::new(&"./video/Big Buck Bunny 720P.m4v", 1920, 1080).unwrap();
Now, you need to load a model,
let model: Model = Model::default();
Optionally, you may define a callback function. This is useful if you want updates on the progress of VMAF score calculation
let callback = |status: VmafStatus| match status {
VmafStatus::Decode => dostuff(),
VmafStatus::GetScore => dostuff(),
};
Now we construct a Vmaf
context
let vmaf = Vmaf::new(
VmafLogLevel::VMAF_LOG_LEVEL_DEBUG,
num_cpus::get().try_into().unwrap(),
0,
0,
)
To get a vector of scores for every frame, we may use the following method on our new Vmaf
context:
let scores = vmaf
.get_vmaf_scores(reference, distorted, model, Some(callback))
.unwrap();