Ogg Opus

A decoder/encoder for Ogg Opus in Rust

Usage

Add to your cargo.toml

toml ogg-opus = "^0.1"

Minimum Rust version

Since we use const generics, the minimum version of Rust is 1.51

Example

Encode

This example makes use of wav crate, you can use it adding to your cargo.toml file:

toml wav = "^1.0"

rust let mut f = File::open("my_file.wav").unwrap(); let (_, b) = wav::read(&mut f).unwrap(); let audio = b.try_into_sixteen().unwrap(); let opus = ogg_opus::encode::<16000, 1>(&audio).unwrap();

Decode

Read from file

rust let mut f = File::open("my_file.ogg").unwrap(); let (raw, header) = ogg_opus::decode::<_,16000>(f).unwrap();

Read from Vec

```rust use std::io::Cursor;

// Let's say this vec contains Ogg Opus data let opus: Vec = Vec::new(); let (raw, header) = ogg_opus::decode::<_,16000>(Cursor::new(opus)).unwrap(); ```

What works and what not