Skip to main content

High-performance audio decoding with FFmpeg and C++

Project description

AvioFlow

AvioFlow is a high-performance audio decoding and capture library powered by FFmpeg. It provides a modern C++20 API and seamless Python bindings for efficient audio processing, including file decoding, URL streaming, and low-latency system audio capture (WASAPI/DirectShow).

Features

  • Multi-format Support: Decodes any format supported by FFmpeg (MP3, WAV, AAC, FLAC, etc.).
  • Flexible Input: Load audio from files, memory buffers, network URLs, or custom streams.
  • Hardware Capture:
    • WASAPI Loopback: Capture system output (what you hear).
    • DirectShow: Capture from microphones and other input devices.
  • Resampling: Built-in support for target sample rate and channel conversion.
  • Node-API Support: Modern ESM-ready Node.js bindings for real-time audio processing.
  • Python Bindings: High-performance Python module using pybind11.
  • Static Linking: Fully static build support (FFmpeg + CRT) for easy distribution without external DLL dependencies.

🛠 Build Instructions

Prerequisites

  • Windows: Visual Studio 2022+, CMake 3.20+.
  • Linux: GCC 11+, CMake 3.20+, FFmpeg development headers.

Windows

Use the provided PowerShell script for a full build (includes Node.js and Python):

.\build.ps1

Or for a specific Node.js build:

npm install
# npx cmake-js compile
npm run prebuild

Linux

Compile with shared or static FFmpeg (default is shared):

cmake -B build -DENABLE_PYTHON=ON -DENABLE_WASAPI=ON
cmake --build build --config Release

📦 Prebuildify (Node.js)

Generate prebuilt binaries for all Node.js versions:

npm run prebuild

This will strip symbols and tag them for compatibility (Node >= 16).


🚀 C++ Usage

Offline File Decoding

#include "avioflow-cxx-api.h"
#include <iostream>

int main() {
    avioflow::AudioStreamOptions options;
    options.output_sample_rate = 16000; // Resample to 16kHz
    options.output_num_channels = 1;    // Convert to Mono

    avioflow::AudioDecoder decoder(options);
    decoder.open("audio.mp3");

    auto meta = decoder.get_metadata();
    std::cout << "Codec: " << meta.codec << " Duration: " << meta.duration << "s" << std::endl;

    // Decode all at once
    auto samples = decoder.get_all_samples();
    std::cout << "Decoded " << samples.data[0].size() << " samples." << std::endl;

    return 0;
}

System Audio Capture (WASAPI)

decoder.open("wasapi_loopback");
while (!decoder.is_finished()) {
    auto frame = decoder.decode_next();
    if (!frame.data.empty()) {
        // Process real-time float samples...
    }
}

🐍 Python Usage

install command:

pip install avioflow

Basic Decoding

import avioflow 

# Initialize and open
decoder = avioflow.AudioDecoder()
decoder.open("music.wav")

# Get info
meta = decoder.get_metadata()
print(f"Container:    {meta.container}")
print(f"Codec:        {meta.codec}")
print(f"Sample Rate:  {meta.sample_rate} Hz")
print(f"Channels:     {meta.num_channels}")
print(f"Duration:     {meta.duration:.3f} s")
print(f"Num Samples:  {meta.num_samples}")

# Decode all samples, with multi-channels
print(f"\nDecoding all samples...")
samples = decoder.get_all_samples()

Real-time Capture

# List available devices
devices = avioflow.DeviceManager.list_audio_devices()
for d in devices:
    print(f"ID: {d.name}, Desc: {d.description}")

decoder = avioflow.AudioDecoder()
decoder.open("audio=@device_cm_...") # Open microphone via DirectShow string

while True:
    frame = decoder.decode_next()
    if frame:
        # data is planar float32
        process(frame.data)

📦 Node.js Usage

Installation

Directly from npm:

npm install avioflow

ESM Example

import avioflow from 'avioflow';

const decoder = new avioflow.AudioDecoder();
decoder.open("TownTheme.mp3");

const meta = decoder.getMetadata();
console.log(`Codec: ${meta.codec}, Duration: ${meta.duration}s`);

while (!decoder.isFinished()) {
    const frame = decoder.decodeNext();
    if (frame) {
        // frame.data is an array of Float32Arrays (one per channel)
        console.log(`Decoded ${frame.channels} channels`);
    }
}

Device Discovery

const devices = avioflow.listAudioDevices();
devices.forEach(dev => {
    console.log(`${dev.isOutput ? 'Output' : 'Input'}: ${dev.name}`);
});

⚙️ Static Compilation Details

AvioFlow supports fully static builds on Windows to eliminate external dependencies:

  • FFmpeg: Statically linked into the binary.
  • CRT: Using /MT to statically link the C Runtime Library, avoiding the "VC++ Redistributable" requirement.

To enable this in your own CMake project:

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# Link to avioflow (which should be built with BUILD_SHARED_LIBS=OFF)

License

MIT License

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.

avioflow-0.1.6-cp313-cp313-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.13Windows x86-64

avioflow-0.1.6-cp313-cp313-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

avioflow-0.1.6-cp312-cp312-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.12Windows x86-64

avioflow-0.1.6-cp312-cp312-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

avioflow-0.1.6-cp311-cp311-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.11Windows x86-64

avioflow-0.1.6-cp311-cp311-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

avioflow-0.1.6-cp310-cp310-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.10Windows x86-64

avioflow-0.1.6-cp310-cp310-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

avioflow-0.1.6-cp39-cp39-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.9Windows x86-64

avioflow-0.1.6-cp39-cp39-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

avioflow-0.1.6-cp38-cp38-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.8Windows x86-64

avioflow-0.1.6-cp38-cp38-manylinux_2_28_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

File details

Details for the file avioflow-0.1.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: avioflow-0.1.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for avioflow-0.1.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 be3d9a0326ed417b70b54540b2bc1d02a58f9daba4f587475e1d9f7a9b9e905c
MD5 ef9b4fa83cd87dc245c11689eca4ebbf
BLAKE2b-256 015246d96f2d9f458b73e98e9d9478904ef7f345e17a2ed0404db8d208bc45c0

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for avioflow-0.1.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 01aaf5d787c2b666c5ad278534394c07ed06ac79bd8016f21b24419b2efdcc74
MD5 3fa8da29c06fda9d0d65499b7d8481af
BLAKE2b-256 63c04d354e8bef2df9300d71fd8c958a20b800f604d5d3a549b08274d2d79976

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: avioflow-0.1.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for avioflow-0.1.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 61e9499218db74a287e48b3fe92dee367a0466004c39cd7f98574fd3b486527a
MD5 2f39195745a806279c8a359ad4c5a74e
BLAKE2b-256 82bd29e6813c5e6919ff37ea881f0f5c02c7a5706e448a201d3aea966a4024a8

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for avioflow-0.1.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02f4682b2c44af43db45a785d4baf7a71ee524a52be9b6e63a4771df4c56fac7
MD5 4b2be9961c146a0a2c4db51b79d3683a
BLAKE2b-256 977d216b5691005e46e26516ada1f7bb3402bda91620d66ba2e5b6b7c1a2bda4

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: avioflow-0.1.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for avioflow-0.1.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 80c09e2d92f27d8c889d73e693ed8b0d882f092e1caa3f3c3304ecf07dfd0e58
MD5 308d7ff210af81974bd884087cc63e9f
BLAKE2b-256 ae6eef16c4af16b0c4d915997a8cceeaba14879f914ce0ce272a19c6782722b8

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for avioflow-0.1.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e56891077bcb443e1ab1ed795124d2c7a90fcb9608af272c63aec7cb36eea1a
MD5 e95869b536c90020b662a206ae7b5522
BLAKE2b-256 ee9ec2d5fcf6afbc1d8b941c04c33c853444feb1f2d665e83b99bdee2a56b8f5

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: avioflow-0.1.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for avioflow-0.1.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 40a85cc4c3fbf7cd96e37ca50ffefdd1e63b02e83276958cca19b3d08bc8586d
MD5 89d2470dc2768648dfc773541ac1dd0e
BLAKE2b-256 fb406127ce82f1bb5217cb80a9fda1dbb3875c3cf4ac3d6dc8bf8979c5d9d050

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for avioflow-0.1.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a05a8856342bb598e755cb1304cd8cdf57e11b10b00bcf71d950ebba2a3a2ca4
MD5 4de478bcebe94e570b41cd72bb863663
BLAKE2b-256 7327cbf392cbc043200697cefaff93e64f20b463cbb799c5fb5aa06943895f52

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: avioflow-0.1.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for avioflow-0.1.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6ccd5eb59847973b2d562e27eddcb3a6012984cb14de7f503f9cba00640ab00b
MD5 7de013471ed0fdef004b662a8daca810
BLAKE2b-256 8349cb68b32f036abf277b84426846e2cda1f0c7071868c7fc5e88eeb25ec7c0

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for avioflow-0.1.6-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a4082884e19250d167bfc2ac24728d80bf7f8aac79ea6b2b912b97d9e1d54de7
MD5 a6de7ac1e7f0e424122c963b994c4c40
BLAKE2b-256 8ccd78fce65c170778ce2b1fb7ab864854157fc7d105a424d775f1531f1efdd7

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: avioflow-0.1.6-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 12.8 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for avioflow-0.1.6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 06fea4225d8779a401c204e6a2273ce00ce19405940e5bf50add4250d64c31c7
MD5 cbb099e53e8e13ba9c2820e839599c71
BLAKE2b-256 fe657f8207a6dbfb13c1d96416857ebe00bcf75f29aa7076c9828ce2a879ae71

See more details on using hashes here.

File details

Details for the file avioflow-0.1.6-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for avioflow-0.1.6-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f5b890ef66991e4d6124798b99a7d9941148d378ca5565c8e1d229d6b2ba4e56
MD5 3368729f4fef0aebacb806db4cc498a0
BLAKE2b-256 2f28daf6085b3690f3195c60fa8491fb250f73a25dd8c75fac2a225c4be4c98f

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