Skip to main content

Crate rff_codec_opus

Crate rff_codec_opus 

Source
Expand description

Opus audio codec, backed by our pure-Rust rusty_opus (BSD-3-Clause, our performance fork of opus-rs, a port of libopus 1.6 — no FFI).

Opus works in f32 samples at one of 8/12/16/24/48 kHz, in fixed frame durations; we use 20 ms frames. The encoder buffers incoming audio and emits one Opus packet per frame; the decoder turns each packet back into an AudioFrame. Sample rate + channel count reach the decoder via configure (typically from an OpusHead).

Frames may arrive as interleaved s16 or f32; both are accepted (decoded output is f32).

When the stream’s OpusHead (RFC 7845) arrives as extradata — as from the Ogg demuxer — the decoder honours it the way FFmpeg does: the pre-skip is dropped from the start, the output gain is applied, the last packet is trimmed to the final granule position (Packet::end_position) — or, from Matroska/WebM (whose CodecPrivate is the same OpusHead), by the last block’s DiscardPadding (Packet::discard_padding). Multichannel (mapping family ≠ 0) streams are refused as unsupported.

Functions§

register
Register the Opus codec into a CodecRegistry.