Python library for PipeWire video capture with pre-built wheels
Project description
pipewire-capture
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/failureget_stream_info()- Returns(fd, node_id, width, height)tuple orNoneclose()- Release resources
CaptureStream
Captures frames from a PipeWire stream.
CaptureStream(fd, node_id, width, height, capture_interval=0.25)- Create streamstart()- Start capturingget_frame()- Get latest frame as numpy array (BGRA)window_invalid- Property: True if window was closedstop()- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pipewire_capture-0.2.8-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pipewire_capture-0.2.8-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86307c74968549861f6d4620f58fd8a7fd620077467134300bbaa8923512d298
|
|
| MD5 |
6eb4fe6b370d715895df49cc6d9c041e
|
|
| BLAKE2b-256 |
f3c0e1f5bd546021c6f333744b976502ea0aea30f4365aff8a5e8c98888a8adc
|
Provenance
The following attestation bundles were made for pipewire_capture-0.2.8-cp39-abi3-manylinux_2_34_x86_64.whl:
Publisher:
publish.yml on bquenin/pipewire-capture
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pipewire_capture-0.2.8-cp39-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
86307c74968549861f6d4620f58fd8a7fd620077467134300bbaa8923512d298 - Sigstore transparency entry: 834512279
- Sigstore integration time:
-
Permalink:
bquenin/pipewire-capture@0035d858009bd252d2317008987227de84503c04 -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/bquenin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0035d858009bd252d2317008987227de84503c04 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pipewire_capture-0.2.8-cp39-abi3-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: pipewire_capture-0.2.8-cp39-abi3-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a566d5f09c4708fbf709a2b8147c84ca2b51dfa44d25e0e412a5e8bd3c4970b4
|
|
| MD5 |
6a1bc7fe7e5e492ed65c8d6a99db3863
|
|
| BLAKE2b-256 |
b0fc29512ba49491a333dd14c9970236bad49ad3362daf6c56afe62fda28457a
|
Provenance
The following attestation bundles were made for pipewire_capture-0.2.8-cp39-abi3-manylinux_2_34_aarch64.whl:
Publisher:
publish.yml on bquenin/pipewire-capture
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pipewire_capture-0.2.8-cp39-abi3-manylinux_2_34_aarch64.whl -
Subject digest:
a566d5f09c4708fbf709a2b8147c84ca2b51dfa44d25e0e412a5e8bd3c4970b4 - Sigstore transparency entry: 834512284
- Sigstore integration time:
-
Permalink:
bquenin/pipewire-capture@0035d858009bd252d2317008987227de84503c04 -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/bquenin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0035d858009bd252d2317008987227de84503c04 -
Trigger Event:
release
-
Statement type: