Giter VIP home page Giter VIP logo

node-lame's Introduction

node-lame

NodeJS native bindings to libmp3lame & libmpg123

Build Status

For all your async streaming MP3 encoding/decoding needs, there's node-lame! This module hooks into libmp3lame, the library that the lame command uses, to provide Encoder and Decoder streams to NodeJS.

Installation

node-lame comes bundled with its own copy of libmp3lame and libmpg123, so there's no need to have them installed on your system.

Simply compile and install node-lame using npm:

$ npm install lame

Example

Here's an example of using node-lame to encode some raw PCM data coming from process.stdin to an MP3 file that gets piped to process.stdout:

var lame = require('lame');

// create the Encoder instance
var encoder = new lame.Encoder({
  // input
  channels: 2,        // 2 channels (left and right)
  bitDepth: 16,       // 16-bit samples
  sampleRate: 44100,  // 44,100 Hz sample rate

  // output
  bitRate: 128,
  outSampleRate: 22050,
  mode: lame.STEREO // STEREO (default), JOINTSTEREO, DUALCHANNEL or MONO
});

// raw PCM data from stdin gets piped into the encoder
process.stdin.pipe(encoder);

// the generated MP3 file gets piped to stdout
encoder.pipe(process.stdout);

See the examples directory for some more example code.

API

Decoder class

The Decoder class is a Stream subclass that accepts MP3 data written to it, and outputs raw PCM data. It also emits a "format" event when the format of the MP3 file is determined (usually right at the beginning).

Encoder class

The Encoder class is a Stream subclass that accepts raw PCM data written to it, and outputs a valid MP3 file. You must specify the PCM data format when creating the encoder instance. Only 16-bit signed samples are currently supported (rescale before passing to the encoder if necessary)...

node-lame's People

Contributors

arunoda avatar beneidel avatar fazendaaa avatar gierschv avatar joeblynch avatar linusu avatar ndfred avatar paixaop avatar shine-on avatar suldashi avatar timothygu avatar tootallnate avatar xp1 avatar yhbyun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.