pinray 0.1.1

Multi-platform screen capture library for Rust
docs.rs failed to build pinray-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

pinray

Cross-platform screen and audio capture for Rust

Crates.io Documentation License: MIT

Raw screen and audio capture with a clean backend trait boundary. Capture first, encode separately.

  • Native backends: Wayland (XDG Portal + PipeWire), macOS (ScreenCaptureKit), Windows (DXGI + WGC)
  • Rich frame model with stride, pixel format, color space, timestamps
  • Source enumeration before capture
  • Restore tokens to skip permission dialogs

Install

cargo add pinray

Example

use pinray::{SessionBuilder, PixelFormat, CursorMode};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let sources = pinray::enumerate_sources()?;

    let mut session = SessionBuilder::new()
        .video_target(sources.first().expect("no sources"))
        .pixel_format(PixelFormat::Bgra8888)
        .cursor_mode(CursorMode::Embedded)
        .build()?;

    session.start()?;

    loop {
        match session.next_event(None)? {
            pinray::CaptureEvent::Video(frame) => {
                println!("{}×{} stride={}", frame.width, frame.height, frame.stride);
            }
            pinray::CaptureEvent::End => break,
            _ => {}
        }
    }

    session.stop()?;
    Ok(())
}

Platform Support

Platform Video Audio
Linux Wayland Done
Linux X11 planned
macOS planned planned
Windows planned planned

Requirements

Linux: Wayland session with XDG Desktop Portal, PipeWire, D-Bus

macOS: ScreenCaptureKit (macOS 12.3+)

Windows: Windows 10 1903+ for WGC

License

Licensed under the MIT License. For any inquiries, contact: rupamgolui@proton.me