# mp3d

> Get the duration of an MP3 file

Latest version **2.1.1** (published 2019-09-30) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2019-09-30 |
| First published | 2019-03-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=0.11.0 |
| Dependencies | 2 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Han de Boer |
| Maintainers | paraself |
| Keywords | mp3, duration, length, file, audio |

## Links

- npm: https://www.npmjs.com/package/mp3d
- Repository: https://github.com/paraself/mp3d
- Issues: https://github.com/paraself/mp3d/issues
- npm.io page: https://npm.io/package/mp3d

## Dependencies (2)

- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1
- [bluebird-co](https://npm.io/package/bluebird-co.md) ^2.2.0

## Recent versions

- 2.1.1 (latest) — 2019-09-30
- 2.1.0 — 2019-03-18
- 2.0.0 — 2019-03-18

## README

# mp3d

> Calculate duration of an MP3

The original version has a bug that output mp3 duration is seconds instead of milliseconds. In order to prevent any future api change risk. A fork version is created here.

## Install

```
$ npm install --save mp3d
```

## Usage

```javascript
var mp3Duration = require('mp3d');

mp3Duration('file.mp3', function (err, duration) {
  if (err) return console.log(err.message);
  console.log('Your file is ' + duration + ' seconds long');
});
```

## API

## mp3Duration(filePathOrBuffer [, cbrEstimate] [, callback])

### filePathOrBuffer

Type: `string` | `Buffer`

Path to the file or a buffer with the file's contents

### cbrEstimate

Defaults to `false`. When set to `true`, will estimate the length of a
constant-bitrate mp3. This speeds up the calculation a lot but isn't
guaranteed to be accurate.

### callback(error, duration)

Type: `function`

Callback to be called once duration is calculated. It's also possible to
instead use the returned `Promise`. `duration` is the duration of the
mp3 in `ms`.

### Return value

`mp3Duration` returns a Promise that resolves to the duration of the mp3 in `seconds` or rejects with some error.

## License

MIT © Han de Boer

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