The NIF does not load

  • Confirm a precompiled artifact exists for your target (aarch64-apple-darwin, x86_64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl, x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl).
  • Or build from source with RUSTY_OPUS_BUILD=1 mix compile and Rust 1.89.0 installed.
  • A :bad_lib/Function not found error means the loaded .so does not match the compiled module — recompile after code changes (mix clean && mix compile).

Errors

reasonMeaning
:invalid_ratesampling rate not in 8000/12000/16000/24000/48000
:invalid_settingschannel count or application invalid
:invalid_settingan option value is out of its documented range
:invalid_inputframe_size/PCM length mismatch or non-binary input
:invalid_pcmPCM byte length is not a multiple of 4
:encode_failed / :decode_failedthe codec rejected the input
:codec_panickedthe codec panicked on hostile input; the resource is now unusable
:closedthe codec resource was closed

Common issues

  • "expected N f32 samples ... got M" — the PCM passed to encode/3 must contain exactly frame_size * channels samples. Split your buffer into frames first.
  • Decoded audio sounds delayed/shortopus-rs decodes with codec lookahead; compare by energy (RMS) rather than per-sample, and buffer a few frames before use.
  • Tiny packets for a quiet clip — silent frames encode to a few bytes at every bitrate; use a loud region to compare bitrate effects.
  • Windows targets — not yet published; use a source build or a supported target.

QA

The authoritative quality gate is:

bin/qa_check.sh

It runs Elixir formatting/compile/tests, Rust format/check/clippy/tests, and source, path, provenance, and package audits.