Borewit/music-metadata

No duration in metadata.format when using parseBuffer

Closed this issue · 1 comments

Is there an existing issue for this?

  • I have searched the existing issues

music-metadata version

7.14.0

JavaScript module eco system

ECMAScript modules (ESM), music-medata ≥ version 8

Current Behavior

Given the provided file, I never receive duration in the format output

const fs = require('node:fs')
const path = require('node:path')
const mm = require('music-metadata')

;(async () => {
  const filePath = path.resolve(__dirname, 'test-123.mp3')
  const fileBuffer = fs.readFileSync(filePath)
  const attrs = { mimeType: 'audio/mpeg'}
  const options = { duration: true, skipCovers: true, skipPostHeaders: true }
  console.log((await mm.parseFile(filePath, attrs, options)).format)
  console.log((await mm.parseBuffer(fileBuffer, attrs, options)).format)
})()
{
  tagTypes: [],
  trackInfo: [],
  lossless: false,
  container: 'MPEG',
  codec: 'MPEG 2.5 Layer 1',
  sampleRate: 11025,
  numberOfChannels: 1,
  bitrate: 112000
}
{
  tagTypes: [],
  trackInfo: [],
  lossless: false,
  container: 'ADTS/MPEG-4',
  codec: 'AAC',
  sampleRate: undefined,
  numberOfChannels: 2,
  bitrate: NaN
}

I also note that it's odd that parseBuffer and parseFile return different outputs for the same file.

Expected Behavior

I expect metadata.format.duration to contain the duration of the audio

Attached audio sample?

  • I have provided sufficient information to reproduce the

test-123.zip

MP3 file is corrupt, I cannot play it with foobar2000.