#screen-capture #graphics #window-capture #media #window

wgrab

GPU-only screen capture library exposing captured frames as wgpu textures

1 unstable release

0.1.0 Jun 2, 2026

#565 in Hardware support

MIT/Apache

330KB
7K SLoC

CrabGrab 🦀 🖥️ 🦀

A cross-platform screen-capturing crate for rust

Project status

ihasq/wgrab is maintained as a successor fork of CrabGrab.

The current direction is to preserve the CrabGrab API surface while modernizing the internal platform and GPU interop implementation, including current wgpu support.

GPU-only direction

wgrab now treats WgpuCaptureFrame as the primary capture output.

CPU-readable bitmap APIs and raw platform capture output APIs have been removed from the GPU-only branch. Use WgpuVideoFrameGpuOnlyExt::get_wgpu_capture_frame for new code.

Current distribution

The GPU-only branch is being prepared for crates.io publication as wgrab. Real publishing still requires explicit owner approval.

Installation

wgrab is being prepared for crates.io publication.

Until publication, use Git:

wgrab = { git = "https://github.com/ihasq/wgrab", branch = "wgrab-crates-io-prep" }

After registry publication:

wgrab = "0.1"

The primary API is GPU-only and centered on WgpuCaptureFrame.

Future web target

A future goal is browser capture via getDisplayMedia -> VideoFrame -> WebGPU, while preserving wgrab's GPU-only design.

Crates.io Version docs.rs MacOS Documentation

Capturing video from screens and applications can be very hard, and it's even worse when you want to do it in a cross-platform application. CrabGrab makes it easy to do continuous frame capture that can be used for individual screenshots or for capturing video. It also includes common functionality needed for enumerating screens and applications. You can get from a window to a pixel buffer in just a few lines of code that will work on both Windows and MacOS.

#[tokio::main]
async fn main() { 
    let token = match CaptureStream::test_access(false) {
        Some(token) => token,
        None => CaptureStream::request_access(false).await.expect("Expected capture access")
    };
    let filter = CapturableContentFilter::NORMAL_WINDOWS;
    let content = CapturableContent::new(filter).await.unwrap();
    let config = CaptureConfig::with_display(content.displays().next().unwrap(), CapturePixelFormat::Bgra8888);

    let mut stream = CaptureStream::new(token, config, |stream_event| {
        // The stream_event here could be a video frame or audio frame
        println!("result: {:?}", stream_event);
    }).unwrap();

    std::thread::sleep(Duration::from_millis(2000));

    stream.stop().unwrap();
}

With CrabGrab, you can build things like:

  1. An AI assistant that can see your screen. A fully functional AI assistant built on top of CrabGrab can be seen in the open source Snippy project.

Snippy, an AI assistant

  1. A screen recording tool like the Augmend client.

Augmend, a video capture tool

Features:

  • Screen and window capture supported
  • Compatible with multiple GPU APIs:
    • Wgpu
    • DX11
    • DXGI
    • Metal
    • IOSurface
  • Easy frame bitmap generation
  • Platform specific extension features
  • Screenshot facility
  • Sound capture (WIP)

Examples

For a full application example, check out Snippy, an AI assistant built on top of CrabGrab.

Small examples showing how to use the CrabGrab crate can be found at crabgrab/examples. You can run the examples from the repository:

cargo run --example <example_name>

Note that feature examples will require that feature:

cargo run --example <example name> --feature <feature name>

MacOS Docs

Unfortunately due to our dependence on metal-rs, building docs for macos doesn't work on docs.rs, since they use linux containers. As a workaround, we host macos documentation in this repository - link above.

Contributions

All contributions are welcome! We are actively working on this project and are looking to expand the capabilities including sound capture, Linux support, and performance improvements.

Dependencies

~0.8–37MB
~596K SLoC