What is it?
It was originally a fork of https://github.com/Garciat/libvorbis.js (and also its ancestors). API has been totally re-designed and simplified. Now it has been a lower layer part of WebAudioRecorder.js.
lib/ contains library files.
OggVorbisEncoder.min.js.mem: memory initializer data for OggVorbisEncoder.min.js
Uncompressesd library is a single file. You can use it from both HTML and Web Worker.
- from HTML:
- from Worker:
Using minified library is same way. But you must pay attention to memory initializer location.
- from HTML: default directory is same as HTML which loads OggVorbisEncoder.min.js
- from Worker: default directory is same as OggVorbisEncoder.min.js path
To change memory initializer path from HTML:
encoder = new OggVorbisEncoder(sampleRate, numChannels, quality)
Create an encoder object.
samleRate: sampling rate [Hz]
numChannels: number of audio channels
quality: Vorbis quality (
-0.1 <= quality <= 1)
- encoder object
Current implementation supports VBR encoding only.
Encode audio buffers.
buffers: array of sample buffers (
[Float32Array, Float32Array ...])
buffers must be an array of Float32Array audio data (range = [-1, 1]). Array length must be same as number of channels. It supports stream (incremental) processing. Sample buffers are processed to Ogg Vorbis stream and appended to internal data.
blob = encoder.finish([mimeType])
Finish encoding and get Ogg Vorbis as a Blob.
mimeType(optional): MIME type (default =
- Blob object
.finish(), all internal data is cleared (to avoid resource leak). You must create a new encoder object to encode another audio data.
Cancel encoding and clear all internal data.
You should call
.cancel() manually to avoid resource leak when recording is canceled (encoder's internal memory is not deallocated by unbinding an object variable).
Emscripten and ruby are required to build the library.
Download and extract libogg + libvorbis, build library files (see Rakefile for more details).