Skip to main content

Python bindings and self-contained Opus CLI builds with QEXT enabled by default.

Project description

opuscodec

Python bindings and self-contained Opus CLI builds, with QEXT enabled by default.

opuscodec packages three things together:

  • OpusBufferedEncoder / OpusBufferedDecoder Python bindings
  • self-contained opusenc / opusdec release binaries
  • vendored Xiph dependencies, built from source when needed

Stable dependency set:

  • opus 1.6.1
  • opus-tools 0.2
  • libogg 1.3.6
  • opusfile 0.12
  • libopusenc 0.3

Why this package

  • no system Opus install required by default
  • runtime + build-time QEXT control
  • Python API and CLI assets released from one repo
  • PyPI wheels for supported targets, source build fallback everywhere else

Installation

PyPI (recommended)

python -m pip install opuscodec==0.1.3

GitHub Release asset

python -m pip install "https://github.com/fishaudio/opuscodec/releases/download/v0.1.3/<wheel-file-name>.whl"

Example Linux wheel install commands. Exact manylinux policy tags may include more than one compatible tag.

python -m pip install ./opuscodec-0.1.3-cp312-cp312-*x86_64.whl
python -m pip install ./opuscodec-0.1.3-cp312-cp312-*aarch64.whl

Source build

make test

Common commands:

make install    # editable install + test deps
make test       # run pytest
make wheel      # build wheel into dist/wheels
make binaries   # build opusenc/opusdec into dist/bin
make clean      # clean build artifacts

Python example

import numpy as np
import opuscodec

sr = 48000
x = (0.1 * np.sin(2 * np.pi * 440 * np.arange(sr) / sr) * 32767).astype(np.int16).reshape(-1, 1)

enc = opuscodec.OpusBufferedEncoder(sample_rate=sr, channels=1)
packet = enc.write(x) + enc.flush()

dec = opuscodec.OpusBufferedDecoder()
y = dec.decode(packet)

print(y.shape, opuscodec.opus_version(), opuscodec.qext_enabled(), enc.qext_enabled())

Disable runtime QEXT for one encoder instance:

enc = opuscodec.OpusBufferedEncoder(sample_rate=48000, channels=1, qext=False)

Standalone binary usage

After downloading release binaries:

tar -xzf opuscodec-v0.1.3-linux-amd64-binaries.tar.gz
tar -xzf opuscodec-v0.1.3-linux-arm64-binaries.tar.gz
chmod +x opusenc opusdec

WAV roundtrip

./opusenc input.wav output.opus
./opusdec output.opus roundtrip.wav

opusenc enables QEXT by default in this repository build. Disable it explicitly for comparison tests:

./opusenc --set-ctl-int 4056=0 input.wav output-noqext.opus

Raw PCM roundtrip

Encode raw PCM (mono, 48k, s16le) to Opus:

./opusenc --raw --raw-bits 16 --raw-rate 48000 --raw-chan 1 input.pcm output.opus

Decode Opus back to PCM:

./opusdec output.opus decoded.pcm

Build configuration

Defaults: vendored dependencies; QEXT enabled.

Optional environment variables:

  • OPUSCODEC_ENABLE_QEXT=0 — disable QEXT
  • OPUSCODEC_USE_SYSTEM_DEPS=1 — use system libraries instead of vendored build
  • OPUSCODEC_DEPS_PREFIX=/path/to/prefix — custom dependency prefix

When QEXT is enabled at build time, packaged opusenc binaries also enable OPUS_SET_QEXT(1) by default.

Repository layout

.
├── .github/workflows/build.yml
├── Makefile
├── pyproject.toml
├── setup.py
├── src/
│   └── opuscodec_bindings.cpp
├── scripts/
│   ├── build_deps.sh
│   └── build_binaries.sh
├── tests/
│   └── test_bindings.py
├── opusenc.py
└── opusdec.py

Release automation

On tag push (for example v0.1.3), GitHub Actions will:

  • run tests on Linux + macOS
  • build PyPI-compatible manylinux wheels for Linux x86_64 + aarch64
  • build macOS arm64 wheels
  • build an sdist
  • publish wheel + sdist artifacts to PyPI via OIDC
  • create a GitHub Release and upload wheels + binary tarballs

License

Apache License 2.0. See 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 Distribution

opuscodec-0.1.3.tar.gz (11.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

opuscodec-0.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (456.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

opuscodec-0.1.3-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (445.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

opuscodec-0.1.3-cp312-cp312-macosx_11_0_universal2.whl (531.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ universal2 (ARM64, x86-64)

opuscodec-0.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (454.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

opuscodec-0.1.3-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (443.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

opuscodec-0.1.3-cp311-cp311-macosx_11_0_universal2.whl (525.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file opuscodec-0.1.3.tar.gz.

File metadata

  • Download URL: opuscodec-0.1.3.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for opuscodec-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1c78c3a2a860596e10a01d99ba167cb0eb484549e1ff41850bbb581f60e24b35
MD5 56f9c6005d71889792b39104dbfd1381
BLAKE2b-256 2d86fb93253d6f216b8c1bec92373377205f8bfcf1748f86b8013fce3bf9a2a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for opuscodec-0.1.3.tar.gz:

Publisher: build.yml on fishaudio/opuscodec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opuscodec-0.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for opuscodec-0.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 46cdd92e44efac0b4069afb3b937a2723b74034ab61e69884531853e06294728
MD5 c4197792fc6bd896085ff37889215c30
BLAKE2b-256 4f9c7aaa1c2ed82885e92f7302ed9896befd80dd022b2b514450e6ab1a6ad862

See more details on using hashes here.

Provenance

The following attestation bundles were made for opuscodec-0.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on fishaudio/opuscodec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opuscodec-0.1.3-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for opuscodec-0.1.3-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8173f41b538a6cc1a306f573fe43753d8227617de8bc08e6b69e016369be662d
MD5 ea287903ddc718e2dfa2c1388ecb01f9
BLAKE2b-256 42215cf31a5eafa387ad731d7f74771448865dfa9b3c7ab58a8ab316f3a7087a

See more details on using hashes here.

Provenance

The following attestation bundles were made for opuscodec-0.1.3-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build.yml on fishaudio/opuscodec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opuscodec-0.1.3-cp312-cp312-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for opuscodec-0.1.3-cp312-cp312-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 c33f874ab7cf3dea623998ecdf4440799c9ce628718c4e8911249158cd0ead8b
MD5 f6d98e1d90d00678fd2e34ebd85684a7
BLAKE2b-256 364da17bb525037cb2d21df041ab94ec14dba4a257d02c590bbda8faf94549d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for opuscodec-0.1.3-cp312-cp312-macosx_11_0_universal2.whl:

Publisher: build.yml on fishaudio/opuscodec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opuscodec-0.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for opuscodec-0.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 335fffc02c6f446bfa239e0fde142f33dae19922f67483ac26002b596e46e631
MD5 68a2a9e6c1af8721799fb3ddb9cca695
BLAKE2b-256 f1165dfd5fde922125f1c633ed55f269294130f9220fdc8e48abf95506e7ba05

See more details on using hashes here.

Provenance

The following attestation bundles were made for opuscodec-0.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on fishaudio/opuscodec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opuscodec-0.1.3-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for opuscodec-0.1.3-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dfbc27275340a81010ffab8e9bd05fed5decdb0cc382bcda0f7cd2ac256a637d
MD5 d92e882c56f6c4f38e62099342082a39
BLAKE2b-256 bd5e62e60ee787cc49286e7605680c4ed2d935108572738e927658b56c8bf45f

See more details on using hashes here.

Provenance

The following attestation bundles were made for opuscodec-0.1.3-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build.yml on fishaudio/opuscodec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opuscodec-0.1.3-cp311-cp311-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for opuscodec-0.1.3-cp311-cp311-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 176826a0c99b4848e9a52eb60ee82cf4dee41d50c33bad9300343b6f22e9bb2f
MD5 278bbc5da20e91fdd3c7bcda4f781d81
BLAKE2b-256 f73dd841af484c6f7ffab9384d3734674857fa74ea65d80344fdbee86a9c6850

See more details on using hashes here.

Provenance

The following attestation bundles were made for opuscodec-0.1.3-cp311-cp311-macosx_11_0_universal2.whl:

Publisher: build.yml on fishaudio/opuscodec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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