@audio/ encode-ogg
Status calibrated
npm1.3.1licenseMIT
Encode PCM audio samples to OGG Vorbis format via WASM
Overview
- Install
- Updated
- Family
- encode, 14 packages under it
- Tags
- read & write
Encode PCM audio samples to OGG Vorbis format.
WASM (libvorbis via wasm-media-encoders) — works in both node and browser.
import ogg from '@audio/encode-ogg';
const encoder = await ogg({ sampleRate: 44100, channels: 1, quality: 5 });
const chunk = encoder.encode(channelData); // → Uint8Array (OGG pages)
const tail = encoder.flush(); // → Uint8Array (remaining)
Options
| Option | Default | Description |
|---|---|---|
sampleRate |
— | Sample rate (required) |
channels |
auto | 1 (mono) or 2 (stereo). Auto-detected from first encode call. |
quality |
3 |
VBR quality −1 to 10 (higher = better) |
Streaming
const encoder = await ogg({ sampleRate: 44100, channels: 1 });
const a = encoder.encode(chunk1);
const b = encoder.encode(chunk2);
const c = encoder.flush();
// complete OGG = concat(a, b, c)
encoder.free();
Streaming output
stream: true with meta: the comment header is rewritten as the stream goes and later pages are renumbered on the fly, so tags never hold the output back.
License
MIT