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/OpusBufferedDecoderPython bindings- self-contained
opusenc/opusdecrelease binaries - vendored Xiph dependencies, built from source when needed
Stable dependency set:
opus1.6.1opus-tools0.2libogg1.3.6opusfile0.12libopusenc0.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.2
GitHub Release asset
python -m pip install "https://github.com/fishaudio/opuscodec/releases/download/v0.1.2/<wheel-file-name>.whl"
Example Linux wheel name:
python -m pip install ./opuscodec-0.1.2-cp312-cp312-manylinux_2_28_x86_64.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.2-linux-amd64-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 QEXTOPUSCODEC_USE_SYSTEM_DEPS=1— use system libraries instead of vendored buildOPUSCODEC_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.2), GitHub Actions will:
- run tests on Linux + macOS
- build PyPI-compatible manylinux wheels for Linux
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opuscodec-0.1.2.tar.gz.
File metadata
- Download URL: opuscodec-0.1.2.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed6d11cc7b340322bd28196813369ec6716163f0916b09296a6becee2e99b23f
|
|
| MD5 |
2ce045595fac851080259ccd319265a6
|
|
| BLAKE2b-256 |
f46158b7ae266f49d6d1ecdb34ce8ec246557a2aff300e89c1256ddd23b7c5c7
|
Provenance
The following attestation bundles were made for opuscodec-0.1.2.tar.gz:
Publisher:
build.yml on fishaudio/opuscodec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opuscodec-0.1.2.tar.gz -
Subject digest:
ed6d11cc7b340322bd28196813369ec6716163f0916b09296a6becee2e99b23f - Sigstore transparency entry: 1052273102
- Sigstore integration time:
-
Permalink:
fishaudio/opuscodec@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/fishaudio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Trigger Event:
push
-
Statement type:
File details
Details for the file opuscodec-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: opuscodec-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 456.0 kB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9aed87b65343cfdc430642b92dc0cde565c9ccc1c7831b3bedbaa2c4411c373
|
|
| MD5 |
4c142841e253a936fc801201acb137c9
|
|
| BLAKE2b-256 |
67ead1ecfacd669d7b039092b6747979bf41b586a3c407c670c4f49bde0f7340
|
Provenance
The following attestation bundles were made for opuscodec-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build.yml on fishaudio/opuscodec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opuscodec-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
c9aed87b65343cfdc430642b92dc0cde565c9ccc1c7831b3bedbaa2c4411c373 - Sigstore transparency entry: 1052273174
- Sigstore integration time:
-
Permalink:
fishaudio/opuscodec@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/fishaudio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Trigger Event:
push
-
Statement type:
File details
Details for the file opuscodec-0.1.2-cp312-cp312-macosx_11_0_universal2.whl.
File metadata
- Download URL: opuscodec-0.1.2-cp312-cp312-macosx_11_0_universal2.whl
- Upload date:
- Size: 530.8 kB
- Tags: CPython 3.12, macOS 11.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67db0c2f3b88919ca336c576571b4c3e8ba404daced209c0a3d05a39d574fe49
|
|
| MD5 |
a79d74c0d1f71f9b0630094287e3646d
|
|
| BLAKE2b-256 |
afe92fae0e96f2db16d8695fc80fd2b698fdd83c8b668680eaab3362f6a43422
|
Provenance
The following attestation bundles were made for opuscodec-0.1.2-cp312-cp312-macosx_11_0_universal2.whl:
Publisher:
build.yml on fishaudio/opuscodec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opuscodec-0.1.2-cp312-cp312-macosx_11_0_universal2.whl -
Subject digest:
67db0c2f3b88919ca336c576571b4c3e8ba404daced209c0a3d05a39d574fe49 - Sigstore transparency entry: 1052273302
- Sigstore integration time:
-
Permalink:
fishaudio/opuscodec@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/fishaudio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Trigger Event:
push
-
Statement type:
File details
Details for the file opuscodec-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: opuscodec-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 453.9 kB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
438e42f27f474c372d9f779058da8b45d68daa25a0e8c52a7bffa7604fc7fbca
|
|
| MD5 |
733b431a9e97043f832387319b10e257
|
|
| BLAKE2b-256 |
ab6e0764d0cbf4f08ad597934294831b25fbdddc61717c2068dace5b395de225
|
Provenance
The following attestation bundles were made for opuscodec-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build.yml on fishaudio/opuscodec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opuscodec-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
438e42f27f474c372d9f779058da8b45d68daa25a0e8c52a7bffa7604fc7fbca - Sigstore transparency entry: 1052273329
- Sigstore integration time:
-
Permalink:
fishaudio/opuscodec@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/fishaudio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Trigger Event:
push
-
Statement type:
File details
Details for the file opuscodec-0.1.2-cp311-cp311-macosx_11_0_universal2.whl.
File metadata
- Download URL: opuscodec-0.1.2-cp311-cp311-macosx_11_0_universal2.whl
- Upload date:
- Size: 524.7 kB
- Tags: CPython 3.11, macOS 11.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eee5d359b6c92f6ed36dba3fa459b39370e760c4eacf687dac6d000d991c7127
|
|
| MD5 |
3d3ad22f99585f16e8e4d2e23ce3e25d
|
|
| BLAKE2b-256 |
a6420d3e7f7acaa1e8b7cf8baa988d4626a2c2d01c8706fa8aee559e36a367dd
|
Provenance
The following attestation bundles were made for opuscodec-0.1.2-cp311-cp311-macosx_11_0_universal2.whl:
Publisher:
build.yml on fishaudio/opuscodec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opuscodec-0.1.2-cp311-cp311-macosx_11_0_universal2.whl -
Subject digest:
eee5d359b6c92f6ed36dba3fa459b39370e760c4eacf687dac6d000d991c7127 - Sigstore transparency entry: 1052273237
- Sigstore integration time:
-
Permalink:
fishaudio/opuscodec@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/fishaudio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@7ba585b94f31568a148ea9dad4094a87c5dbd163 -
Trigger Event:
push
-
Statement type: