Skip to content

audiojs/ogg-encode

Repository files navigation

@audio/ogg-encode

Encode PCM audio samples to OGG Vorbis format.
WASM (libvorbis via wasm-media-encoders) — works in both node and browser.

npm install @audio/ogg-encode

import ogg from '@audio/ogg-encode';

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();

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors