JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6114
  • Score
    100M100P100Q134049F
  • License MIT

Get the duration of an MP3 file

Package Exports

  • mp3-duration

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mp3-duration) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

mp3-duration Travis-Build

Calculate duration of an MP3

Install

$ npm install --save mp3-duration

Usage

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