@flat/lame

中文文档
1.2.8发布于 2024/06/06MITTypeScriptCommonJS近 30 天下载 1997

NodeJS native bindings to libmp3lame & libmpg123.

原始使用文档
文档目录6 节
  1. NodeJS native bindings to libmp3lame & libmpg123
  2. Installation
  3. Example
  4. API
  5. Decoder class
  6. Encoder class

node-lame

NodeJS native bindings to libmp3lame & libmpg123

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 @flat/lame

Example

Here's an example of using @flat/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('@flat/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)...

版本与发布记录

@flat/lame 共发布 6 个版本,首次发布于 2015/09/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.8latest2024/06/062 年前
1.2.72023/09/173 年前
1.2.52022/09/094 年前
1.2.62022/09/094 年前
1.2.32015/09/0711 年前
1.2.22015/09/0711 年前

关于 @flat/lame 的常见问题

@flat/lame 是什么?

NodeJS native bindings to libmp3lame & libmpg123.

如何安装 @flat/lame?

在项目目录运行 npm install @flat/lame,或使用 pnpm add / yarn add / bun add。

@flat/lame 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@flat/lame 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@flat/lame 可以商用吗?

@flat/lame 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@flat/lame 的下载量有多少?

根据 npm 官方下载统计,@flat/lame 在 2026/10/15 – 2026/11/13 这 30 天内被下载 1,997 次,日均约 67 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flat/lame 还在维护吗?

最新版本 1.2.8 发布于 2024/06/06(2 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2015/09/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。