Skip to content
Opus bindings for Node.js
JavaScript C++ Shell C Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Add unit tests May 6, 2017
deps add android support Oct 10, 2019
examples Added mp3-to-ogg example Oct 25, 2015
lib Remove deprecated Buffer methods Oct 26, 2017
src Update to Node v12 May 27, 2019
test Fix decoder tests with newer Node versions Dec 9, 2018
.gitattributes Add unit tests May 6, 2017
.gitignore Add unit tests May 6, 2017
.jshintrc Initial commit Apr 27, 2015
.npmignore Fix encoder errors Aug 2, 2016
.travis.yml travis: cache node_modules Sep 17, 2018
LICENSE Update Oct 10, 2017
binding.gyp Initial commit Apr 27, 2015
index.js Made ogg-packet an optional dependency Apr 7, 2017
package-lock.json Version 0.3.2 May 27, 2019
package.json Version 0.3.3 Oct 15, 2019


NodeJS native bindings to libopus

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

Platform support

Supported platforms:

  • Linux x64 & ia32
  • Linux ARM (Raspberry Pi 1 & 2)
  • Linux ARM64 (Raspberry Pi 3)
  • Mac OS X x64
  • Windows x64

Add new supported platforms by running ./ 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
./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.

You can’t perform that action at this time.