Skip to main content

A performant audio capture pipeline that encodes raw PCM to Opus, skipping silence.

Project description

pcmflux

pcmflux is a high-performance audio capture and encoding module for Python.

It is designed to capture system audio using PulseAudio, encode it into the Opus format, and stream it with low latency. A key optimization is its ability to detect and discard silent audio chunks, significantly reducing network traffic and CPU usage during periods of no sound.

Prerequisites

This package compiles a C++ extension and requires the development headers for PulseAudio and Opus to be installed on your system.

On Debian/Ubuntu, you can install them with:

sudo apt-get install libpulse-dev libopus-dev

Core Features

  • PulseAudio Capture: Uses the pa_simple API for efficient, low-level audio capture.
  • Opus Encoding: Integrates the high-quality, low-latency Opus codec.
  • Silence Detection: Intelligently skips encoding and sending silent audio chunks.
  • Python ctypes Wrapper: Provides a clean and simple Python API over a high-performance C++ core.
  • CMake Build System: Uses a robust CMake setup for compiling the C++ module and its dependencies.

Example Usage

The example directory contains a standalone demo that captures system audio, broadcasts it over a WebSocket, and plays it back in a web browser using the WebCodecs API.

To run the example:

  1. Install the module: pip3 install .
  2. Run the server: python3 example/audio_to_browser.py
  3. Open http://localhost:9001 in a modern web browser (Chrome, Edge, etc.).

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

pcmflux-1.0.2.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file pcmflux-1.0.2.tar.gz.

File metadata

  • Download URL: pcmflux-1.0.2.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for pcmflux-1.0.2.tar.gz
Algorithm Hash digest
SHA256 111b63b01c3731bf4ffce11324b511402b98f5afd5f0f55599e99f825736ccd9
MD5 cb9eaa1e5b9161342941cee0f6bf4584
BLAKE2b-256 40f29ba98950e8cfe53855e60a925e003f86d3b86658844ef6f05a392e0c5015

See more details on using hashes here.

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