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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.8Windows x86-64

avioflow-0.1.4-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.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: avioflow-0.1.4-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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ac4585c17fc94880f5f7f9f800d2abf47064890ac0a7201aaa18adf6c1bd3270
MD5 974da020838dcb37a1e4dd76492ced37
BLAKE2b-256 55f8eb0ee2e5f9aabee1997d3ac81d2c42c114bf18ce74efe19bdc00d45c2e37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0567823cbd81affda290f67324c0baf3bf5c46d82da1ef77d974254842faf342
MD5 b0236ff3ef43fbd981e0616dcf7437c7
BLAKE2b-256 28a02115940d9d10109d1d0eb250646e5dd03f55e58ea98e454578ada36ed6f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.4-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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1d85134bd8069e528a3ae0ed71d816fa9ef150318d00dd7a262bffb6db34291d
MD5 94a13f88f685119006d57a14a70acb0c
BLAKE2b-256 5109cce5f96c88f424e74c60d9c8715077269c6471c1c4361c7418073e0f6fc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4e5f0359b3e269f5570008c29eb621ecf4c4e36eb67926eb8b9a6c6058783c88
MD5 244387d2661e9a466777dfca40b64b57
BLAKE2b-256 8bec1a5871baf5fb60a463e509a6af2d5d1a66d1c3ec9d34a7f0e7fb9695b396

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.4-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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e862d1fcb36f5598e07242c2c581bc9500ba398e742d2906d93959afddc3c3e4
MD5 7ab5a202dcc7ff2a6ce7812baa36d79a
BLAKE2b-256 8803080d77ff1c5e97730d9fd3db584c7145e6f6a973a9c9de5c0fb092ff17b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a80918b9a650e51b940ad5acd698ea094da6000957138c6a2226f95789e56815
MD5 52bde9b56bb0319299dfde8fc3e74ff4
BLAKE2b-256 283a32856737e62c8ff3697600e04ce46c41c179453481d4dd812b8d52038de0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.4-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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d7241861df71d0b3e9b025ba62d0e147fa8db5c72a483de0352d682a639d7b44
MD5 4858444fed7050790916b1066914f7d7
BLAKE2b-256 fdc5f7d49a6a85401563d7b2f90570a8497d68cc5c9d295dd05d0568bb6c9c68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 712583204e599673983df06b00b0a5287ed26b2b87c933cea017a68e7049826d
MD5 a40fe9ef8d44e5b18c0c283b61606ba6
BLAKE2b-256 a191a77986023b84e8002d2435c67362932ae3e1c4c2b195f2f075b5ccdd1f61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.4-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.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6c54289bcecce4f71732b5f8473bd2a6b0031c0102d934c904fb5151d4c74443
MD5 160a0737e64ccba60b78f9ca394688d2
BLAKE2b-256 27478a2f839a0073ab2798bf392244e795af60168dc568bf6d1c94f7c2457b5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.4-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 69bf61ba18138d35798914dff18c1f9c280f6f81a3ef691bade3c983a7a51abc
MD5 866d49d45d3b029512137d720647e4c6
BLAKE2b-256 17d7cee475fae2a612ddd4c79fe9780a72ada7585a965c4bb4b7388fc6889ee1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: avioflow-0.1.4-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.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c77f9e1284bd0a7ffad46785e74070064f3a0783968323fa28f10abc2c2d38ba
MD5 fe26e155a0ab95377a0c79e1ef88ffad
BLAKE2b-256 5441bffa16cf9d32db3273b3527f4bc3bacaf1fca65c0d19f6399540fa1b1fe2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for avioflow-0.1.4-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7966fa8c5effabffee7ce4b218167bd7f6aa318e950ce142c374d9cda81b941f
MD5 6a34ad5bb8d9c79219ec49be2f7f4063
BLAKE2b-256 ade0cdd984d9c2a195194d33b5ed5255ecd6bff343e83d413e8b8e970b326af3

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