Skip to content

Dublin-Digital-Radio/mp3-duration

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mp3-duration Travis-Build

Calculate duration of an MP3 in seconds

Install

$ npm install --save mp3-duration

Usage

import mp3Duration = from 'mp3-duration';

try {
  const duration = await mp3Duration('file.mp3');
  console.log('Your file is ' + duration + ' seconds long');
} catch (err) {
  console.log(err.message);
}

API

mp3Duration(filePathOrBuffer [, cbrEstimate])

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.

Return value

duration is the duration of the mp3 in seconds (including fractional seconds).

License

MIT © Han de Boer

About

Get the duration of an MP3 file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%