English | 简体中文
An audio codec library that statically links FFmpeg, avoiding the hassle of pre-installed dependencies. Provides both a Rust API and Python bindings.
- Bundles a static FFmpeg; zero external shared-library dependencies at runtime.
- Decoding: AAC, AC-3, ALAC, APE, FLAC, MP1/2/3, Opus, Vorbis, WavPack, various PCM/ADPCM, and more.
- Encoding: WAV, AIFF, FLAC, ALAC, AAC, MP3 (LAME), Opus, Vorbis.
- Optional resampling, downmixing, range trimming, normalization, and more.
pip install codecpodPre-built wheels are published to PyPI for Linux x86_64, macOS (Apple Silicon and Intel), and Windows x86_64.
Building requires the following toolchain:
- A Rust toolchain; the latest stable is recommended.
nasm,clang, andlibclang.make,pkg-config.
On Windows the FFmpeg sources are built with autotools, so the toolchain must be the GNU
(MinGW-w64) one rather than MSVC: build inside an MSYS2 UCRT64
shell and target x86_64-pc-windows-gnullvm.
Build and install into the current environment:
uvx maturin develop --releaseOr produce a wheel:
uvx maturin build --releaseThe first build downloads the FFmpeg and dependency source tarballs from upstream, pinned to the exact versions and SHA-256 checksums in
build.rs. This takes a while, so make sure your network connection is stable.If the
CODECPOD_VENDOR_DIRenvironment variable is set, the build skips downloading and uses the sources there directly. Seebuild.rsfor the directory layout.
import codecpod
import numpy as np
# Read audio metadata
info = codecpod.info("input.flac")
print(info.sample_rate, info.channels, info.frames, info.codec)
# Decode audio; returns (ndarray, sample_rate) by default, with channels_first=True
waveform, sample_rate = codecpod.load("input.flac")
# Resample to 16 kHz and downmix to mono while decoding
waveform, sample_rate = codecpod.load(
"input.flac",
sample_rate=16000,
mono=True,
)
# Encode to MP3 with explicit encoder parameters
codecpod.save(
"output.mp3",
waveform,
sample_rate,
codec=codecpod.Mp3(bit_rate=192000),
)Copyright (C) 2026 zhoukz <me@zhoukz.com>
This project is distributed under LGPL-2.1-or-later; see LICENSE.
It statically links several third-party libraries; see
THIRD-PARTY-NOTICES.md for details.