Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Github banner

Discord Twitter GitHub Repo stars docs.rs Crates.io MSRV

A Rust library for high-quality screen capture that leverages native OS APIs for optimal performance!

  1. macOS: ScreenCaptureKit
  2. Windows: Windows.Graphics.Capture
  3. Linux: Pipewire

Features

  1. Cross-platform across Windows, Mac and Linux!
  2. Checks for support and recording permissions.
  3. Query list of captureable targets (displays and windows).
  4. Exclude certain targets from being captured.

Contributing

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:

  1. Clone the repo and run it with cargo run.
  2. Explore the API and library code in lib.rs.
  3. Platform-specific code lives in the win, mac and linux modules.
  4. The main.rs is a small program that "consumes" the library, for easy testing.

Usage

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();
}

Python bindings

The optional Python extension is built with maturin and returns captured data as owned NumPy arrays. Install a development build with:

python -m pip install maturin numpy
maturin develop --features python

Example:

import scap

if not scap.has_permission():
    if not scap.request_permission():
        raise RuntimeError("screen capture permission was denied")

options = scap.CaptureOptions(
    fps=30,
    output_type="bgra",
    output_resolution="720p",
)
capturer = scap.Capturer(options)
capturer.start()
try:
    frame = capturer.next_frame()
    print(frame.data.shape, frame.data.dtype, frame.format)
finally:
    capturer.stop()

Video arrays currently contain the native packed byte order reported by frame.format (rgb, rgbx, xbgr, bgrx, bgr0, or bgra) and have shape (height, width, channels). Audio arrays contain the owned raw bytes as a one-dimensional uint8 NumPy array; AudioFrameInfo exposes the sample format, channel count, sample rate, sample count, and planar layout.

The extension is feature-gated, so normal Rust builds are unchanged. macOS requires Screen Recording permission.

Linux capture backends

On Linux, PyScap prefers PipeWire through the XDG Desktop Portal. This remains the recommended backend for normal Wayland desktop screen sharing because the portal provides user-controlled source selection. Set SCAP_BACKEND=pipewire to require it.

For X11 desktops and headless virtual displays, set SCAP_BACKEND=x11. The X11 backend connects to the server named by DISPLAY and captures that screen's root window. It uses MIT-SHM when the X server permits it and falls back to the core X11 GetImage request otherwise. X11 capture is display-level; it does not provide the portal's interactive window or monitor picker.

When captures_audio=True, Linux records stereo 48 kHz signed 16-bit PCM from the default PulseAudio/PipeWire-Pulse output monitor. Set SCAP_AUDIO_SOURCE to override the source name. The PulseAudio client libraries and a running audio server must be available; headless systems normally need a null sink for Chromium to produce capturable audio.

For example, start Xvfb and capture its 1920x1080 screen:

Xvfb :99 -screen 0 1920x1080x24 &
DISPLAY=:99 SCAP_BACKEND=x11 python capture.py

An explicit backend is never silently replaced by another backend. With no SCAP_BACKEND, PyScap probes PipeWire and the ScreenCast portal first, then falls back to X11 when DISPLAY points to a usable X server.

License

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.

Contributors

Pranav Joglekar
Pranav Joglekar

💻
Siddharth
Siddharth

💻
Rohan Punjani
Rohan Punjani

💻
NiiightmareXD
NiiightmareXD

💻
MAlba124
MAlba124

💻
Anubhav Singhal
Anubhav Singhal

💻
Vasu Sharma
Vasu Sharma

💻

Credits

This project builds on top of the fabulous work done by:

Metadata

Release files for lexian-pyscap 0.1.2b11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lexian-pyscap 0.1.2b11
File Size Uploaded Provenance Actions
lexian_pyscap-0.1.2b11.tar.gz 5.2 MB With provenance Details for lexian_pyscap-0.1.2b11.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for lexian-pyscap 0.1.2b11
File Actions
lexian_pyscap-0.1.2b11-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for lexian_pyscap-0.1.2b11-cp313-cp313-win_amd64.whl
lexian_pyscap-0.1.2b11-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details for lexian_pyscap-0.1.2b11-cp313-cp313-manylinux_2_34_x86_64.whl
lexian_pyscap-0.1.2b11-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for lexian_pyscap-0.1.2b11-cp313-cp313-macosx_11_0_arm64.whl
lexian_pyscap-0.1.2b11-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details for lexian_pyscap-0.1.2b11-cp313-cp313-macosx_10_12_x86_64.whl

Total release size: 10.3 MB

Release files / lexian_pyscap-0.1.2b11.tar.gz

Download URL lexian_pyscap-0.1.2b11.tar.gz
Size 5.2 MB
Tags Source
SHA-256 checksum
How to use checksums
642bd4f0a25ebc75e0e0a9eff3e61a685fe2c5dbe39e440464aadd1b25d5ce55
BLAKE2b-256 checksum
How to use checksums
3ed12bdd77eb04dd6a5dbe6d4abd50b1e7a908fde797772548bc3f96654e935f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lexian_pyscap-0.1.2b11-cp313-cp313-win_amd64.whl

Download URL lexian_pyscap-0.1.2b11-cp313-cp313-win_amd64.whl
Size 348.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
f2b6060aec3e8bc81acea35a6a8cfd1c457b5e9d0c0f702bc0cb5ef926ef754f
BLAKE2b-256 checksum
How to use checksums
2da780d8d690b39096c000ee4b1d907ec151eba68bae8297ced169264bf30dca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lexian_pyscap-0.1.2b11-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL lexian_pyscap-0.1.2b11-cp313-cp313-manylinux_2_34_x86_64.whl
Size 4.0 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
378c8688401afa0217d9416e03cb95e3124a75aa978a813bc894240456a4b7d9
BLAKE2b-256 checksum
How to use checksums
ce1aecf5c91a771961de3efa3a148e69d941ec7ceb699e0d31c2b96519cb0947
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lexian_pyscap-0.1.2b11-cp313-cp313-macosx_11_0_arm64.whl

Download URL lexian_pyscap-0.1.2b11-cp313-cp313-macosx_11_0_arm64.whl
Size 360.6 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4cc00da2d528302c6daa212d29adf101f0fc4eeb14f97053ac4ecc54f6202d86
BLAKE2b-256 checksum
How to use checksums
53dd40cc5b03f66fb663d1775ca13e1c40e1c69435884b24929725ee743c5340
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / lexian_pyscap-0.1.2b11-cp313-cp313-macosx_10_12_x86_64.whl

Download URL lexian_pyscap-0.1.2b11-cp313-cp313-macosx_10_12_x86_64.whl
Size 363.3 kB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
824305fb6fc3b3be7fc260136c8f70ef79a43cc0c0886b94096568df6698c3e8
BLAKE2b-256 checksum
How to use checksums
b98fb714310da53702b631f0a4800c08f2ca7bf73a27bffe28ead13aab33b0af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Security for lexian-pyscap 0.1.2b11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for lexian_pyscap-0.1.2b11.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page