ProcessAudioCapture
A Windows DLL for capturing audio from specific processes (applications).
Overview
ProcessAudioCapture uses the AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS API introduced in Windows 10 version 2004 (Build 19041) to capture audio output from a specific process only.
Unlike system-wide loopback capture (which records all audio), this library allows you to:
- Record audio from a single application (e.g., browser, game, media player)
- Exclude a specific application's audio from recording
- Monitor real-time audio levels from a specific process
Based on Microsoft's official ApplicationLoopback sample.
Features
- Process-specific capture - Record audio from only the specified process (INCLUDE mode)
- Process exclusion - Record all audio except from the specified process (EXCLUDE mode)
- Real-time level monitoring - Get audio level in dB via callback
- Pause/Resume support - Pause and resume recording without stopping
- WAV file output - Direct output to WAV file
- Process enumeration - List all processes currently outputting audio
- Python bindings included - Ready-to-use Python wrapper
Requirements
- OS: Windows 10 version 2004 (Build 19041) or later, or Windows 11
- Build Environment (if building from source):
- Visual Studio 2019/2022 with C++ Desktop Development
- Windows 10 SDK (10.0.19041.0 or later)
- CMake 3.16 or later
Installation
Using Prebuilt Binaries
Download the latest release from the Releases page.
Extract and use:
ProcessAudioCapture.dll- The main DLLpython/process_audio_capture.py- Python wrapper
Building from Source
cd ProcessAudioCapture
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64
cmake --build . --config Release
Output files:
build/bin/Release/ProcessAudioCapture.dllbuild/bin/Release/TestCapture.exe
Quick Start
Python
from process_audio_capture import ProcessAudioCapture
# Check if Windows version is supported
if not ProcessAudioCapture.is_supported():
print("Windows 10 2004 or later required")
exit()
# List processes outputting audio
processes = ProcessAudioCapture.enumerate_audio_processes()
for p in processes:
print(f"PID: {p.pid}, Name: {p.name}, Window: {p.window_title}")
# Capture audio from a specific process
def on_level(level_db):
print(f"Level: {level_db:.1f} dB")
with ProcessAudioCapture(
pid=target_pid,
output_path="output.wav",
level_callback=on_level
) as capture:
capture.start()
time.sleep(10) # Record for 10 seconds
# capture.stop() is called automatically
C/C++
#include "ProcessAudioCapture.h"
// Check Windows version
if (!PacIsSupported()) {
printf("Windows 10 2004 or later required\n");
return;
}
// List audio processes
PacProcessInfo processes[64];
int count;
PacEnumerateAudioProcesses(processes, 64, &count);
// Start capture
PacHandle handle;
PacErrorCode err = PacStartCapture(
targetPid, // Target process ID
PAC_MODE_INCLUDE, // Capture mode
L"output.wav", // Output file (NULL for monitoring only)
levelCallback, // Level callback (can be NULL)
nullptr, // User data
&handle
);
// During capture...
float levelDb;
PacGetLevel(handle, &levelDb);
// Pause/Resume
PacPauseCapture(handle);
// ... paused ...
PacResumeCapture(handle);
// Stop capture
PacStopCapture(handle);
API Reference
Functions
| Function | Description |
|---|---|
PacIsSupported() |
Check if Windows version is supported |
PacEnumerateAudioProcesses() |
Get list of processes outputting audio |
PacStartCapture() |
Start capturing audio from a process |
PacStopCapture() |
Stop capturing |
PacPauseCapture() |
Pause capturing (audio data not written) |
PacResumeCapture() |
Resume capturing |
PacIsPaused() |
Check if capture is paused |
PacGetLevel() |
Get current audio level in dB |
PacIsCapturing() |
Check if currently capturing |
PacGetLastErrorMessage() |
Get last error message |
PacGetVersion() |
Get DLL version |
Error Codes
| Code | Value | Description |
|---|---|---|
PAC_SUCCESS |
0 | Success |
PAC_ERROR_INVALID_PARAM |
-1 | Invalid parameter |
PAC_ERROR_NOT_SUPPORTED |
-2 | Windows version not supported |
PAC_ERROR_PROCESS_NOT_FOUND |
-3 | Process not found |
PAC_ERROR_AUDIO_INIT_FAILED |
-4 | Audio initialization failed |
PAC_ERROR_FILE_CREATE_FAILED |
-5 | File creation failed |
PAC_ERROR_ALREADY_RECORDING |
-6 | Already recording |
PAC_ERROR_NOT_RECORDING |
-7 | Not recording |
Capture Modes
| Mode | Description |
|---|---|
PAC_MODE_INCLUDE |
Capture only the specified process's audio |
PAC_MODE_EXCLUDE |
Capture all audio except the specified process |
Directory Structure
ProcessAudioCapture/
├── CMakeLists.txt # Build configuration
├── LICENSE # MIT License
├── README.md # This file
├── src/
│ ├── ProcessAudioCapture.h # Public API header
│ ├── ProcessAudioCapture.cpp # DLL implementation
│ ├── LoopbackCapture.h # Internal capture header
│ └── LoopbackCapture.cpp # Internal capture implementation
├── python/
│ └── process_audio_capture.py # Python wrapper
├── test/
│ └── test_capture.cpp # C++ test application
├── prebuilt/ # Prebuilt binaries
│ └── x64/
│ └── ProcessAudioCapture.dll
└── build/ # Build output (CMake generated)
Limitations
- DRM-protected content: Cannot capture (Windows restriction)
- Audio format: Fixed at 48kHz or device default, 32-bit float, stereo
- Child processes: Audio from child processes of the target is also included/excluded
Use Cases
- Recording game audio without microphone
- Capturing browser audio (meetings, videos, music)
- Audio processing pipelines
- Accessibility tools
- Streaming/broadcasting specific application audio
License
MIT License - see LICENSE file.
Based on Microsoft's ApplicationLoopback sample.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
- Microsoft for the ApplicationLoopback sample code
- Windows Audio Session API (WASAPI) documentation
Metadata
Release files for process-audio-capture 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| process_audio_capture-1.0.0.tar.gz | 25.1 kB | Without provenance | Details for process_audio_capture-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| process_audio_capture-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for process_audio_capture-1.0.0-py3-none-any.whl |
Total release size: 47.5 kB
Release files / process_audio_capture-1.0.0.tar.gz
| Download URL | process_audio_capture-1.0.0.tar.gz |
|---|---|
| Size | 25.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
311c45bd9de57bd3f749669cb88b4a47c5c775cfe6d29484e34317fc002ef22f
|
|
BLAKE2b-256 checksum How to use checksums |
eb0be472720cf338708e0b381b35a4fde4bd3f6b4e59f9472c51cf099217c516
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Release files / process_audio_capture-1.0.0-py3-none-any.whl
| Download URL | process_audio_capture-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7654f26fb54f8dab47fa92f50d31b7c4c68cfac9cb7aceafb3cc6637fb2d1595
|
|
BLAKE2b-256 checksum How to use checksums |
1fc0cdd16212c799cb79778ab3ee591a29aa10ea98cc89e4435bb6fbf2cb47f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.4
|
Security for process-audio-capture 1.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.