Calculate duration of an MP3 in seconds
$ npm install --save mp3-duration
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);
}
Type: string
| Buffer
Path to the file or a buffer with the file's contents
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.
duration
is the duration of the mp3 in seconds
(including fractional seconds).
MIT © Han de Boer