RustyOpus
Pure-Rust Opus for Elixir. No C libopus, no ffmpeg, no
external process — shrink real Ogg Opus blobs (or work with raw packets/PCM) in one BEAM
process.
Headline: take an Ogg Opus file/blob and make it smaller with a numeric bitrate:
{:ok, smaller} = RustyOpus.reencode(ogg_blob, bitrate: 20_000)
That is the whole call. Useful ladder values match MemoMoo-style profiles:
8_000, 12_000, 16_000, 20_000, 24_000, 32_000.
Quick start
# Ogg Opus blob → smaller Ogg Opus blob (default path for files)
{:ok, smaller} = RustyOpus.reencode(ogg_blob, bitrate: 20_000)
# Raw packets / PCM (no container)
{:ok, packets} = RustyOpus.encode(pcm, 16_000, 1, bitrate: 24_000)
{:ok, pcm} = RustyOpus.decode(packets, 16_000, 1)
Data contract
- Ogg Opus — RFC 7845 binaries (
audio/ogg/.ogg) forreencode/2. - PCM — little-endian IEEE-754
f32, interleaved for stereo. - Opus packets — raw binaries (no container).
No WebM/MP4. Never launches an external process. See the codec guide.
Features
RustyOpus.reencode/2— Ogg Opus blob → lower bitrate Ogg Opus blob (opus-rs+ thin Ogg)RustyOpus.encode/4,decode/4,transcode/5— whole-stream raw packet/PCM pathRustyOpus.Encoder/Decoder— per-frame control- Dirty-scheduled codec work; panic containment at the NIF boundary
- Checksum-verified precompiled NIFs with source-build fallback
Supported OS
Precompiled NIFs are published for:
- Apple Silicon macOS (
aarch64-apple-darwin) - Intel macOS (
x86_64-apple-darwin) - ARM64 Linux glibc (
aarch64-unknown-linux-gnu) - ARM64 Linux musl / Alpine (
aarch64-unknown-linux-musl) - x86-64 Linux glibc (
x86_64-unknown-linux-gnu) - x86-64 Linux musl / Alpine (
x86_64-unknown-linux-musl)
Other targets can build from source with RUSTY_OPUS_BUILD=1 and Rust 1.89.0.
Technology
| Elixir module | Native crate | Rust packages |
|---|---|---|
RustyOpus | native/rusty_opus_native | opus-rs 0.1.29 |
Development
bin/qa_check.sh
Committed fixtures include real MemoMoo audio_versions Ogg Opus speech blobs for
reencode/2 tests. Tests need neither the live DB nor ffmpeg.
Release
- Bump the version in
mix.exsandnative/rusty_opus_native/Cargo.toml. - Run
bin/qa_check.shand push the green version commit. - Tag
v0.3.2; the release workflow builds and smoke-tests every precompiled NIF. - Publish the Hex package and GitHub release (maintainer step).
License
RustyOpus is licensed under the Apache License 2.0. Bundled codec:
opus-rs (BSD-3-Clause) — see NOTICE and provenance.