Skip to main content

Python library for PipeWire video capture with pre-built wheels

Project description

pipewire-capture

PyPI version

Python library for PipeWire video capture with pre-built wheels.

This library provides PipeWire-based video capture for Wayland Linux environments, using the xdg-desktop-portal ScreenCast interface for window selection. It's distributed as pre-built wheels, so no compilation or system dependencies are needed for installation.

Features

  • Window selection via xdg-desktop-portal (works on GNOME, KDE, Gamescope, etc.)
  • Frame capture via PipeWire streams
  • Pre-built wheels - no compilation required
  • Python 3.9+ support via stable ABI

Installation

pip install pipewire-capture

Requirements

  • Linux with Wayland
  • PipeWire (installed by default on modern Linux distributions)
  • xdg-desktop-portal with ScreenCast support

Usage

from pipewire_capture import PortalCapture, CaptureStream, is_available

# Check if capture is available
if not is_available():
    print("PipeWire capture not available (not running on Wayland)")
    exit(1)

# Show window picker and select a window
portal = PortalCapture()

def on_window_selected(success: bool):
    if not success:
        print("Window selection cancelled")
        return

    # Get PipeWire stream info
    stream_info = portal.get_stream_info()
    if stream_info is None:
        print("No stream available")
        return

    fd, node_id, width, height = stream_info

    # Start capturing frames
    stream = CaptureStream(fd, node_id, width, height, capture_interval=0.25)
    stream.start()

    # Get frames
    for _ in range(10):
        frame = stream.get_frame()  # numpy array (H, W, 4) BGRA
        if frame is not None:
            print(f"Got frame: {frame.shape}")

        if stream.window_invalid:
            print("Window was closed")
            break

    stream.stop()
    portal.close()

portal.select_window(on_window_selected)

API Reference

is_available() -> bool

Check if PipeWire capture is available on this system.

PortalCapture

Handles window selection via xdg-desktop-portal.

  • select_window(callback) - Show window picker, calls callback with success/failure
  • get_stream_info() - Returns (fd, node_id, width, height) tuple or None
  • close() - Release resources

CaptureStream

Captures frames from a PipeWire stream.

  • CaptureStream(fd, node_id, width, height, capture_interval=0.25) - Create stream
  • start() - Start capturing
  • get_frame() - Get latest frame as numpy array (BGRA)
  • window_invalid - Property: True if window was closed
  • stop() - Stop capturing

Building from source

Requirements:

  • Rust toolchain
  • maturin (pip install maturin)
  • PipeWire development libraries
# Development build
maturin develop

# Release build
maturin build --release

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pipewire_capture-0.2.4-cp39-abi3-manylinux_2_34_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

pipewire_capture-0.2.4-cp39-abi3-manylinux_2_34_aarch64.whl (1.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ ARM64

File details

Details for the file pipewire_capture-0.2.4-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pipewire_capture-0.2.4-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6c7696c835d4315a2f7db2dd2ed694b96ebc4a54723498c8f91746679ae215f7
MD5 754b00eada82d17f248dd74c86d38af9
BLAKE2b-256 20144e5893df32ed2f0367387e98ba9da05cf0c3c083e2e8abedda987e890767

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipewire_capture-0.2.4-cp39-abi3-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on bquenin/pipewire-capture

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

File details

Details for the file pipewire_capture-0.2.4-cp39-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for pipewire_capture-0.2.4-cp39-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 7d0d616ed086e343df55be44292bdeee29ea331afa75e411f29a82c2b62e88e8
MD5 1f2b0ebbc1f48c16b9ababb3fba1ea22
BLAKE2b-256 1b83d8c0127efa60ddca3dbe839e4063a3af6a4e3595a85281e24ec4c81f6c60

See more details on using hashes here.

Provenance

The following attestation bundles were made for pipewire_capture-0.2.4-cp39-abi3-manylinux_2_34_aarch64.whl:

Publisher: publish.yml on bquenin/pipewire-capture

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