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.3-cp313-cp313-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.13Windows x86-64

avioflow-0.1.3-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.3-cp312-cp312-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.12Windows x86-64

avioflow-0.1.3-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.3-cp311-cp311-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.11Windows x86-64

avioflow-0.1.3-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.3-cp310-cp310-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.10Windows x86-64

avioflow-0.1.3-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.3-cp39-cp39-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.9Windows x86-64

avioflow-0.1.3-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.3-cp38-cp38-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.8Windows x86-64

avioflow-0.1.3-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.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: avioflow-0.1.3-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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 536419622eea82015fb5683153752addfa36c60fe8f40a2357ff135bb2f77b6f
MD5 2a85fe8f68137c32fc5bdd1058f892b3
BLAKE2b-256 054912325530067f368d2e1ec4d2ea4601c41a7227f1c35aea6a2d5eae61c1da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0cdd53bd3621e56683bca568a351c391028a0de33b18d719bf242d82db0d3e78
MD5 cf4ca80e9e9f000d1fe9c8e92cdf4a9c
BLAKE2b-256 f8ae04f35b7d14edc9b226123f0929b612a289f4c9127ec686c6edc61dad6aca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.3-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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 661c98de58da475ef8833e4652398eba75731a95340193fc48bba37cbf132dca
MD5 7b53c1c5f93f73edb634483ccaaad63b
BLAKE2b-256 af30eab8ac2106e12518cb194ef0c4923f33d3c7d80e08a5bc5a3ba2637aeb94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7346fbfddc341dca4ea66c2c497e54d58ff28dd17270f3ec4b50e452de8950e6
MD5 ca4988cf08f48e87915221ed84fecf87
BLAKE2b-256 1d8adb205bc7701b295ca29caf4e5cb8b4bb8579ef7447bdb65c5914dd087048

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.3-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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 45b8e0acca6a471957c5aee6f797014ce53addfcb7c969cb9a591dedf5131364
MD5 bae2bab2be55bc124d3da852785a73ad
BLAKE2b-256 dec82407d2dc91b5c1eaa1f1a65294a283b4b2dfdfeb93f30d2afc519d3aaec8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 621f2e44e939996f01a10b83b1b7a358a6ff5488c3684c09e9b5d8462871152f
MD5 38d200d04d4b7f90b39473a16e0a92a8
BLAKE2b-256 ae1ed96a41bc6eb3ca8c08e1b823d417a842aff51a9f6d49dbc82684bd15ac86

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.3-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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 40bc3a591698dd9e325a1829eceec322cb2855338b73f0fd89fd553f45928da1
MD5 ba94fea4120e45625b3f328c896568bf
BLAKE2b-256 82b220c9efcaf8aa46d81eb374f66b792a25a8fffcc9b1395e1e54f1a65ae2cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4a661a5adf11a670ee51753f359027a7ef44a341860fa8db3e89a8143325289e
MD5 08b61214da1dc42fe1f47b7571032175
BLAKE2b-256 c224a46d5db36d5b547fdf784c9ff855b972df43b93b77392169c523c6a241c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.3-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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1a431c5fd30dac09bd973c51c2154935613afaf78b132558ea13a5b894df6bb3
MD5 731829f86c802d6c66b14b0369075bce
BLAKE2b-256 7b88dc9d3d6557714a3bbec7b3422ab4d2d817fb207b44249470606af724060a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.3-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9dba566e970c4b6bdc9ae095a0c9569e78e8be394f9085caa995e31839053816
MD5 eb9eae1577c90d7c6e2af3d3de12fb0f
BLAKE2b-256 2102bedd76cd74aac6e1ea71b76a9f7d376f8535bc2dfeb24d435a1100e23e72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.3-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.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 8782066b4df63b9584561c7890f2f78acb8b74e3a43c77b6df78a68f0ba9c65b
MD5 56f43b43a7d613b6adc8ecf811797ed8
BLAKE2b-256 58761ffa4b93f6c1ae937ded3a334964c3cfbc7c4796bc1d923ce7bd1156b957

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.3-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 98010dcb33d416d58a9247494e07ba53f1bdb3d506058cc87e744f4e0ca56af2
MD5 9c1e104a34428b5c9781143055d292b6
BLAKE2b-256 6689371399bd946b4939416f15f601536a5551a84cb183bf73396fccd11af088

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