# ogg

> Node.js native binding to libogg

Latest version **1.2.6** (published 2019-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install ogg
pnpm add ogg
yarn add ogg
bun add ogg
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.6 |
| Published | 2019-03-01 |
| First published | 2012-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 2.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 65 |
| Author | Nathan Rajlich |
| Maintainers | linusu, tootallnate |
| Keywords | ogg, libogg, encode, decode, stream |

## Links

- npm: https://www.npmjs.com/package/ogg
- Repository: https://github.com/TooTallNate/node-ogg
- Homepage: https://github.com/TooTallNate/node-ogg#readme
- Issues: https://github.com/TooTallNate/node-ogg/issues
- npm.io page: https://npm.io/package/ogg

## Dependencies (4)

- [nan](https://npm.io/package/nan.md) 2
- [debug](https://npm.io/package/debug.md) 2
- [bindings](https://npm.io/package/bindings.md) ~1.2.0
- [readable-stream](https://npm.io/package/readable-stream.md) 1.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.2.6 (latest) — 2019-03-01
- 1.2.5 — 2016-07-07
- 1.2.4 — 2016-01-21
- 1.2.3 — 2016-01-20
- 1.2.2 — 2015-12-13
- 1.2.1 — 2015-05-24
- 1.2.0 — 2015-05-07
- 1.1.2 — 2014-07-28
- 1.1.1 — 2013-03-07
- 1.1.0 — 2013-03-07
- 1.0.0 — 2013-02-17
- 0.0.1 — 2012-11-16

## README

node-ogg
========
### Node.js native binding to libogg
[![Build Status](https://travis-ci.org/TooTallNate/node-ogg.svg?branch=master)](https://travis-ci.org/TooTallNate/node-ogg)
[![Build Status](https://ci.appveyor.com/api/projects/status/hoc58iw51lr5fdjg/branch/master?svg=true)](https://ci.appveyor.com/project/TooTallNate/node-ogg/branch/master)


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`.


Installation
------------

`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`:

``` bash
$ npm install ogg
```

__NOTE:__ `node-ogg` requires to be built using `node-gyp` v0.8.0 or newer!


Example
-------

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:

``` javascript
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.


API
---

### Decoder class

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.

### Encoder class

The `Encoder` class is a `Readable` stream where you are given `EncoderStream`
instances and are required to write `ogg_packet`s received from an ogg stream
encoder to them in order to create a valid ogg file.


OGG Stream Decoders/Encoders
----------------------------

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-vorbis]   |      ✓       |      ✓
|   [`node-opus`][node-opus]       |      ✓       |      ✓

[node-vorbis]: https://github.com/TooTallNate/node-vorbis
[node-opus]: https://github.com/Rantanen/node-opus

---
_Source: https://npm.io/package/ogg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
