Skip to content

Node.js native binding to libvorbis

Notifications You must be signed in to change notification settings

Combadge/node-vorbis

This branch is up to date with marek629/node-vorbis:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

28e63c0 · May 24, 2023
Feb 4, 2019
May 22, 2023
Oct 25, 2020
May 22, 2023
May 22, 2023
May 29, 2018
May 24, 2023
May 22, 2023
Mar 2, 2015
May 22, 2023
May 22, 2023
Jan 27, 2013
Oct 25, 2020
May 24, 2023
May 22, 2023

Repository files navigation

node-vorbis

Node.js native binding to libvorbis

This module provides Vorbis Encoder and Decoder classes compatible with node-ogg streams.

Installation

node-vorbis comes bundled with its own copy of libvorbis, so there's no need to have the library pre-installed on your system.

Simply compile and install node-vorbis using npm:

$ npm install @tap-ogg/vorbis

Example

Decoder example:

var fs = require('fs');
var ogg = require('@suldashi/ogg');
var vorbis = require('@tap-ogg/vorbis');
var file = __dirname + '/Hydrate-Kenny_Beltrey.ogg';

var od = new ogg.Decoder();
od.on('stream', function (stream) {
  var vd = new vorbis.Decoder();

  // the "format" event contains the raw PCM format
  vd.on('format', function (format) {
    // send the raw PCM data to stdout
    vd.pipe(process.stdout);
  });

  // an "error" event will get emitted if the stream is not a Vorbis stream
  // (i.e. it could be a Theora video stream instead)
  vd.on('error', function (err) {
    // maybe try another decoder...
  });

  stream.pipe(vd);
});

fs.createReadStream(file).pipe(od);

Encoder example:

var ogg = require('@suldashi/ogg');
var vorbis = require('@tap-ogg/vorbis');

var oe = new ogg.Encoder();
var ve = new vorbis.Encoder();

// not yet implemented...
ve.addComment('ARTIST', 'Bob Marley');

// `process.stdin` *MUST* be PCM float 32-bit signed little-endian samples.
// channels and sample rate are configurable but default to 2 and 44,100hz.
process.stdin.pipe(ve)

// send the encoded Vorbis pages to the Ogg encoder
ve.pipe(oe.stream());

// write the produced Ogg file with Vorbis audio to `process.stdout`
oe.pipe(process.stdout);

See the examples directory for some more example code.

API

Decoder class

Encoder class

About

Node.js native binding to libvorbis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 55.0%
  • C++ 42.2%
  • Python 2.8%