Skip to main content

Cross-platform headless screen and audio capture library and CLI

Project description

recap

Cross-platform headless screen and audio capture library and CLI.

Features

  • Cross-platform: Windows, macOS, and Linux
  • Record an entire monitor or a single window
  • Record system audio (loopback capture)
  • Per-application audio capture (Windows only via WASAPI process loopback)
  • Video-only, audio-only, or audio+video modes
  • Crop support with configurable size and anchor position
  • CLI tool (recap) and importable Python library
  • Rust native backend (PyO3) for Windows, with automatic fallback to pure-Python
  • Uses FFmpeg for encoding/muxing only

Platform Support

Feature Windows macOS Linux
Monitor capture ✓ GDI BitBlt ✓ CoreGraphics ✓ X11 XGetImage
Window capture ✓ PrintWindow ✓ CGWindowListCreateImage ✓ X11 XGetImage
System audio ✓ WASAPI loopback ⚠ Requires BlackHole/Soundflower ✓ PulseAudio monitor
Per-app audio ✓ WASAPI process loopback ✗ Not supported ✗ Not supported
Rust backend
HW encoding NVENC / QSV / AMF VideoToolbox / NVENC NVENC / VAAPI / QSV

macOS Notes

  • Screen Recording permission must be granted in System Settings → Privacy & Security → Screen Recording.
  • System audio capture requires a virtual audio loopback device such as BlackHole. Install BlackHole, then set it as your system output (or use a Multi-Output Device to hear audio simultaneously). Recap auto-detects BlackHole/Soundflower when available.
  • Per-application audio capture is not supported; system-wide audio is captured instead.

Linux Notes

  • Video capture requires X11 (XWayland is acceptable). Native Wayland capture is not yet supported. If running under Wayland, ensure DISPLAY is set for XWayland.
  • Audio capture uses PulseAudio/PipeWire loopback (default.monitor). Ensure pactl is available (pulseaudio-utils or pipewire-pulse).
  • Per-application audio capture is not directly supported; system-wide audio is captured instead.

Requirements

  • Python 3.10–3.13
  • FFmpeg on PATH or specified via --ffmpeg
  • Rust toolchain (only if building from source on Windows)

Platform-specific requirements

  • Windows: Windows 10 version 2004+ for per-app audio capture
  • macOS: macOS 11+ recommended; Screen Recording permission required
  • Linux: X11 or XWayland; PulseAudio or PipeWire; xrandr for multi-monitor detection

Installation

From PyPI (prebuilt wheels)

pip install recap-capture

From source (editable)

Requires maturin and the Rust toolchain (for the Windows native backend):

pip install maturin
git clone https://github.com/Lexian-droid/recap.git
cd recap
maturin develop --release   # builds native backend (Windows only)
pip install -e .

On macOS/Linux, skip the maturin develop step if you don't need the Rust backend — the pure-Python implementations are used automatically.

Architecture

The project has a hybrid Python/Rust structure with a platform abstraction layer:

recap/              Python package (CLI, config, orchestration)
  __init__.py       Public API and version
  _native.py        Bridge to Rust — sets NATIVE_AVAILABLE flag
  cli.py            CLI entry point
  config.py         RecordingConfig dataclass
  recorder.py       Orchestrates capture threads + FFmpeg
  video.py          Platform-dispatching video capture
  audio.py          Platform-dispatching audio capture
  discovery.py      Platform-dispatching monitor/window/device enumeration
  ffmpeg.py         FFmpeg discovery and process wiring
  exceptions.py     Exception hierarchy
  platforms/        Platform abstraction layer
    __init__.py     Platform detection utilities
    macos/          macOS backends (CoreGraphics + FFmpeg avfoundation)
    linux/          Linux backends (X11 + FFmpeg pulse/alsa)

rust_core/          Rust native backend (PyO3/maturin, Windows only)
  src/lib.rs        PyO3 module registration
  src/video.rs      GDI BitBlt / PrintWindow video capture
  src/audio.rs      WASAPI loopback + process loopback audio capture
  src/discovery.rs  Monitor/window/audio device enumeration

Platform dispatch

The video.py, audio.py, and discovery.py modules contain the Windows implementation at the top level. On macOS or Linux, platform-specific implementations are imported from recap/platforms/ and replace the module-level names. This means the public API (from recap import VideoCapture) works identically regardless of platform.

On Windows, the Rust extension (recap._rust_core) can further replace the Python backends with native implementations for maximum performance.

Window-specific recording

When a window is targeted via --window-title or --window-handle:

  • Video is captured using the platform's native window capture API
  • Audio on Windows uses WASAPI process loopback to isolate audio from that process. On macOS/Linux, system-wide audio is captured instead (with a warning).

Releasing

GitHub Actions will publish the package to PyPI when you push a tag that starts with v (e.g. v0.5.0). Wheels are built for Python 3.10–3.13. The Rust native backend is compiled for Windows; macOS and Linux use pure-Python backends.

CLI Usage

# Check environment
recap doctor

# List available capture targets
recap monitors
recap windows
recap devices

# Record primary monitor with audio
recap record --output recording.mp4

# Record a specific window (video + window-specific audio on Windows)
recap record --window-title "Notepad" --output notepad.mp4

# Record video only
recap record --video-only --output silent.mp4

# Record a 1280x720 crop from the top-left of the selected source
recap record --crop-size 1280x720 --crop-position top-left --output cropped.mp4

# Record a centered 1280x720 crop from a specific window
recap record --window-title "Notepad" --crop-size 1280x720 --crop-position middle --output notepad-cropped.mp4

# Record audio only
recap record --audio-only --output audio.wav

# Record for 30 seconds
recap record --duration 30 --output clip.mp4

Crop positions

--crop-position supports:

  • top-left, top-middle, top-right
  • middle-left, middle, middle-right
  • bottom-left, bottom-middle, bottom-right

Center aliases are also accepted (center, top-center, middle-center, etc.).

Library Usage

from recap import Recorder, RecordingConfig

config = RecordingConfig(output="recording.mp4")
recorder = Recorder(config)
recorder.start()
# ... do work ...
recorder.stop()
recorder.wait()

Window-specific recording

from recap import Recorder, RecordingConfig

config = RecordingConfig(
    output="discord.mp4",
    window_title="Discord",
)
recorder = Recorder(config)
recorder.start()
# captures the Discord window's video (and per-app audio on Windows)
recorder.stop()
recorder.wait()

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

recap_capture-0.5.1.tar.gz (54.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

recap_capture-0.5.1-cp313-cp313-win_amd64.whl (262.9 kB view details)

Uploaded CPython 3.13Windows x86-64

recap_capture-0.5.1-cp312-cp312-win_amd64.whl (263.5 kB view details)

Uploaded CPython 3.12Windows x86-64

recap_capture-0.5.1-cp311-cp311-win_amd64.whl (262.8 kB view details)

Uploaded CPython 3.11Windows x86-64

recap_capture-0.5.1-cp310-cp310-win_amd64.whl (262.7 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file recap_capture-0.5.1.tar.gz.

File metadata

  • Download URL: recap_capture-0.5.1.tar.gz
  • Upload date:
  • Size: 54.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for recap_capture-0.5.1.tar.gz
Algorithm Hash digest
SHA256 d7a5bb3ec05b4fa90120192f024aa242d6767fb2ed6cc960a2722faa3fcdf995
MD5 4c01f19d7d0eb450c6c05bd4e4bb10d2
BLAKE2b-256 5bf99e6fdfbad779b5e6c0358d2a72db80a4a07bbe19e652080e29c119d5b8c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for recap_capture-0.5.1.tar.gz:

Publisher: release.yml on Lexian-droid/recap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file recap_capture-0.5.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for recap_capture-0.5.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 859128dd0f68c72e878de98eff65519296a3ba1f8a4d6643bbc9a09325610717
MD5 9b26bdc8ffb1ad1b254710f56e90c83e
BLAKE2b-256 0faa45e39444a60ea0587511eaba6f6a50bb09468cd23a3c80dd0ab2302c939d

See more details on using hashes here.

Provenance

The following attestation bundles were made for recap_capture-0.5.1-cp313-cp313-win_amd64.whl:

Publisher: release.yml on Lexian-droid/recap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file recap_capture-0.5.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for recap_capture-0.5.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d9a477a6c3a1a2c90af9d6b275ea1e3aab0bd56b42ef57e02d36c63783b3feac
MD5 9f7ee5c375d553ec8e0d86c806a09bae
BLAKE2b-256 397918d732329ca3a954086be2fe34a5e4ecdea403b9f02ee68a4dd436f71086

See more details on using hashes here.

Provenance

The following attestation bundles were made for recap_capture-0.5.1-cp312-cp312-win_amd64.whl:

Publisher: release.yml on Lexian-droid/recap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file recap_capture-0.5.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for recap_capture-0.5.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3a578c3d64506738336014fae185aa03938a76fcb496308a69a24cbd98a51faa
MD5 ab4006a010a53b45865982a965d246d0
BLAKE2b-256 1ce1bd895643f2b0b6645c7723265dd8f9298c0607ee2a85eaf3531db02a1bce

See more details on using hashes here.

Provenance

The following attestation bundles were made for recap_capture-0.5.1-cp311-cp311-win_amd64.whl:

Publisher: release.yml on Lexian-droid/recap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file recap_capture-0.5.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for recap_capture-0.5.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cd7c03d708b9ba293af2759cfec2a27b5a3c45a3e96c8345015f6d29b471f5c4
MD5 ac15be6b2fb8539211f7d4f50693cb4a
BLAKE2b-256 edf02210c9fabcbb6e0104b4930616df19263b59acc5cd27ce0a5d40100d32ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for recap_capture-0.5.1-cp310-cp310-win_amd64.whl:

Publisher: release.yml on Lexian-droid/recap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page