npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cfai/video-compare

v2.2.10

Published

WebAssembly video/image comparison library with SSIM, PSNR, MSE metrics - Built with Rust

Readme

@cfai/video-compare

WebAssembly video/image comparison library - Built with 🦀 Rust

npm version License: MIT

🎉 Version 2.0 - Rust 重构

我们自豪地宣布:告别 C++,拥抱 Rust!

为什么选择 Rust?

| 特性 | C++ (v1.x) | Rust (v2.0) | |------|-----------|-------------| | WASM 大小 | ~95KB | ~53KB (-44%) | | 内存安全 | 手动管理 | 编译器保证 | | 构建工具 | cmake + emscripten | cargo + wasm-pack | | 代码质量 | 需谨慎 | 所有权系统 |

安装

npm install @cfai/video-compare

API

import init, {
  compare,
  compare_with_diff,
  compute_pixel_diff,
  get_diff_data,
  get_pixel_diff_data,
  set_compare_config,
  WasmCompareConfig
} from '@cfai/video-compare';

await init();

// 基本对比
const metrics = compare(leftRGB, rightRGB, width, height);
console.log(`SSIM: ${metrics.ssim}, PSNR: ${metrics.psnr}dB`);

// 像素级差异 (精细)
const pixelResult = compute_pixel_diff(leftRGB, rightRGB, width, height);
const pixelData = get_pixel_diff_data(pixelResult);

// 分块级差异 (快速)
const blockResult = compare_with_diff(leftRGB, rightRGB, width, height);
const diffData = get_diff_data(blockResult);

// 配置
set_compare_config(new WasmCompareConfig(1920, 1080, 16));

功能

  • SSIM - 结构相似度指数 (0-1)
  • PSNR - 峰值信噪比 (dB)
  • MSE - 均方误差
  • 像素级差异 - 精细的热力图可视化
  • 分块级差异 - 快速的块状可视化
  • 自动降采样 - 大图自动缩放处理

使用场景

  • 视频编码质量评估
  • 图片压缩效果对比
  • 视频帧实时对比
  • 图像处理算法验证

示例

详见 test.html 包含:

  • 🎥 实时视频对比 - 两路视频实时 SSIM/PSNR 监控
  • 🖼️ 图片对比 - 上传图片查看差异热力图
  • 📈 SSIM趋势图 - 实时折线图追踪质量变化

构建

cargo install wasm-pack
wasm-pack build --target web --out-dir pkg

Comparison with C++ Version

| Feature | C++ (Emscripten) | Rust (wasm-bindgen) | |---------|------------------|---------------------| | Build tool | cmake + emscripten | cargo + wasm-pack | | Package size | ~95KB | ~53KB | | Memory mgmt | Manual _malloc/_free | Automatic | | JS API | ccall/cwrap | Native typed arrays | | Safety | Manual | Rust guarantees |

许可证

MIT License


Made with 🦀 Rust | 告别 C++ 的复杂性,享受 Rust 的安全性