# mp3-duration

> Get the duration of an MP3 file

Latest version **1.1.0** (published 2017-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install mp3-duration
pnpm add mp3-duration
yarn add mp3-duration
bun add mp3-duration
```

## 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.1.0 |
| Published | 2017-10-16 |
| First published | 2015-04-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.11.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 55 |
| Author | Han de Boer |
| Maintainers | ddsol |
| Keywords | mp3, duration, length, file, audio |

## Links

- npm: https://www.npmjs.com/package/mp3-duration
- Repository: https://github.com/ddsol/mp3-duration
- Issues: https://github.com/ddsol/mp3-duration/issues
- npm.io page: https://npm.io/package/mp3-duration

## Dependencies (2)

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

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-10-16
- 1.0.10 — 2016-06-12
- 1.0.9 — 2015-12-10
- 1.0.8 — 2015-12-10
- 1.0.7 — 2015-12-10
- 1.0.6 — 2015-12-10
- 1.0.5 — 2015-04-23
- 1.0.4 — 2015-04-23
- 1.0.3 — 2015-04-23
- 1.0.2 — 2015-04-20
- 1.0.1 — 2015-04-20
- 1.0.0 — 2015-04-19

## README

# mp3-duration ![Travis-Build](https://travis-ci.org/ddsol/mp3-duration.svg?branch=master)

> Calculate duration of an MP3


## Install

```
$ npm install --save mp3-duration
```

## Usage

```javascript
var mp3Duration = require('mp3-duration');

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 `ms` or rejects with some error.

## License

MIT © Han de Boer

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