
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
This module provides a Writable stream interface for decoding ogg files, and a
Readable stream for encoding ogg files. libogg only provides the interfaces
for multiplexing the various streams embedding into an ogg file (and vice versa),
therefore this module is intended to be used in conjunction with a
node-ogg-compatible stream module, like node-vorbis and node-theora.
node-ogg comes bundled with its own copy of libogg, so
there's no need to have the library pre-installed on your system.
Simply compile and install node-ogg using npm:
$ npm install ogg
NOTE: node-ogg requires to be built using node-gyp v0.8.0 or newer!
Here's an example of using the Decoder class and simply listening for the raw
events and console.log()s information about each "packet" emitted from each ogg
stream:
var fs = require('fs');
var ogg = require('ogg');
var file = __dirname + '/Hydrate-Kenny_Beltrey.ogg';
var decoder = new ogg.Decoder();
decoder.on('stream', function (stream) {
console.log('new "stream":', stream.serialno);
// emitted for each `ogg_packet` instance in the stream.
stream.on('data', function (packet) {
console.log('got "packet":', packet.packetno);
});
// emitted after the last packet of the stream
stream.on('end', function () {
console.log('got "end":', stream.serialno);
});
});
// pipe the ogg file to the Decoder
fs.createReadStream(file).pipe(decoder);
See the examples directory for some more example code.
The Decoder class is a Writable stream that accepts an ogg file written to
it, and emits "stream" events when a new stream is encountered. The
DecoderStream instance is a readable stream that outputs ogg_packet Buffer
instances.encountered, which
you are then expected to pass along to a ogg stream decoder.
The Encoder class is a Readable stream where you are given EncoderStream
instances and are required to write ogg_packets received from an ogg stream
encoder to them in order to create a valid ogg file.
Here's a list of known ogg stream decoders and encoders that are compatible with / depend on node-ogg.
Please send pull requests for additional modules if you write one.
| Module | Decoder? | Encoder? |
|---|---|---|
node-vorbis | ✓ | ✓ |
node-opus | ✓ | ✓ |
FAQs
Node.js native binding to libogg
We found that @audc/ogg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.