Upstream is CapSoftware/scap — all credit for this library belongs there. It is MIT licensed, © Cap Software, Inc., and that license and copyright are preserved here unchanged.
This copy is maintained by Luminous Dynamics for use by xenia-peer. It exists because the Linux PipeWire engine did not compile against the current two-level
Frame::Video(VideoFrame::…)enum, and because that engine's internal frame channel was unbounded — under any downstream backpressure it grew without limit (~1.44 GB of 1.47 GB leaked in a 25.76 s heaptrack repro).Both fixes are offered upstream in CapSoftware/scap#183. We are not trying to compete with or replace upstream, and we would rather these changes land there than live here.
This is a deliberately maintained downstream, not an abandoned fork:
- Consumers pin an exact revision, never this branch — a mutable pin is not a pin.
- Changes here stay minimal and are upstreamed first; we do not diverge casually.
- We track upstream and re-sync when it moves. As of this writing upstream
mainlast moved 2025-08-05, which is why the fork exists at all rather than us simply waiting for a release.If you are looking for the real scap, use upstream. If you only need the Linux fixes above, prefer PR #183 landing over depending on this repository.
A Rust library for high-quality screen capture that leverages native OS APIs for optimal performance!
- macOS: ScreenCaptureKit
- Windows: Windows.Graphics.Capture
- Linux: Pipewire
- Cross-platform across Windows, Mac and Linux!
- Checks for support and recording permissions.
- Query list of captureable targets (displays and windows).
- Exclude certain targets from being captured.
We found most of Rust's tooling around screen capture either very outdated, non-performant or platform-specific. This project is our attempt to change that. Contributions, PRs and Issues are most welcome!
If you want to contribute code, here's a quick primer:
- Clone the repo and run it with
cargo run. - Explore the API and library code in lib.rs.
- Platform-specific code lives in the
win,macandlinuxmodules. - The main.rs is a small program that "consumes" the library, for easy testing.
use scap::{
capturer::{Point, Area, Size, Capturer, Options},
frame::Frame,
};
fn main() {
// Check if the platform is supported
if !scap::is_supported() {
println!("❌ Platform not supported");
return;
}
// Check if we have permission to capture screen
// If we don't, request it.
if !scap::has_permission() {
println!("❌ Permission not granted. Requesting permission...");
if !scap::request_permission() {
println!("❌ Permission denied");
return;
}
}
// Get recording targets
let targets = scap::get_all_targets();
println!("Targets: {:?}", targets);
// All your displays and windows are targets
// You can filter this and capture the one you need.
// Create Options
let options = Options {
fps: 60,
target: None, // None captures the primary display
show_cursor: true,
show_highlight: true,
excluded_targets: None,
output_type: scap::frame::FrameType::BGRAFrame,
output_resolution: scap::capturer::Resolution::_720p,
crop_area: Some(Area {
origin: Point { x: 0.0, y: 0.0 },
size: Size {
width: 2000.0,
height: 1000.0,
},
}),
..Default::default()
};
// Create Capturer
let mut capturer = Capturer::build(options).unwrap();
// Start Capture
capturer.start_capture();
let mut input = String::new();
std::io::stdin().read_line(&mut input).unwrap();
// Stop Capture
capturer.stop_capture();
}The code in this repository is open-sourced under the MIT license, though it may be relying on dependencies that are licensed differently. Please consult their documentation for exact terms.
Pranav Joglekar 💻 |
Siddharth 💻 |
Rohan Punjani 💻 |
NiiightmareXD 💻 |
MAlba124 💻 |
Anubhav Singhal 💻 |
Vasu Sharma 💻 |
This project builds on top of the fabulous work done by:
- @MAlba124 for Linux support via Pipewire
- @svtlabs for screencapturekit-rs
- @NiiightmareXD for windows-capture
