|
před 7 roky | |
---|---|---|
.. | ||
bin | před 7 roky | |
build | před 7 roky | |
coverage | před 7 roky | |
deps | před 7 roky | |
examples | před 7 roky | |
lib | před 7 roky | |
node_modules | před 7 roky | |
src | před 7 roky | |
test | před 7 roky | |
.gitattributes | před 7 roky | |
.npmignore | před 7 roky | |
LICENSE | před 7 roky | |
README.md | před 7 roky | |
binding.gyp | před 7 roky | |
index.js | před 7 roky | |
package-lock.json | před 7 roky | |
package.json | před 7 roky |
This module implements bindings for Opus v1.1 for Node.js.
var opus = require('node-opus');
// Create the encoder.
// Specify 48kHz sampling rate and 10ms frame size.
// NOTE: The decoder must use the same values when decoding the packets.
var rate = 48000;
var encoder = new opus.OpusEncoder( rate );
// Encode and decode.
var frame_size = rate/100;
var encoded = encoder.encode( buffer, frame_size );
var decoded = encoder.decode( encoded, frame_size );
// or create streams
var channels = 2;
var opusEncodeStream = new opus.Encoder(rate, channels, frame_size);
var opusDecodeStream = new opus.Decoder(rate, channels, frame_size);
// see examples folder for a more complete example
Supported platforms:
Add new supported platforms by running ./autogen.sh and ./configure in deps/opus and copying the resulting config.h to deps/config/opus/[os]/[arch].
Use the following flags with configure:
./configure --enable-static --disable-shared --with-pic
On a clean debian-based system, the full flow looks approximately like:
sudo apt-get update
sudo apt-get install autoconf
sudo apt-get install libtool
cd deps/opus
./autogen.sh
./configure --enable-static --disable-shared --with-pic
mkdir -p ../config/opus/[os]/[arch]
cp config.h ../config/opus/[os]/[arch]
And, then, the last step is to add the OS/Arch to package.json
.