TooTallNate / node-lame

Node.js native bindings to libmp3lame & libmpg123
MIT License
567 stars 113 forks source link

I use .pipe(new lame.Decoder), but not work #89

Closed klren0312 closed 5 years ago

klren0312 commented 5 years ago
let mp3Stream  = fs.createReadStream(`./${req.file.path}`)

    mp3Stream
      .pipe(new lame.Decoder)
      .pipe(fs.createWriteStream(path.resolve(__dirname, './sample_pcm.pcm')))

the sample_pcm.pcm is empty file

LinusU commented 5 years ago

I would recommend adding error handlers so that you can see what goes wrong, e.g. with the pump utility: https://github.com/mafintosh/pump

const mp3Stream  = fs.createReadStream(`./${req.file.path}`)
const decoder = new lame.Decoder()
const output = fs.createWriteStream(path.resolve(__dirname, './sample_pcm.pcm'))

pump(mp3Stream, decoder, output, (err) => {
  console.error(err.stack)
})
klren0312 commented 5 years ago

I use pump, but it has no err throw, is undefined..., but pcm file is also empty

klren0312 commented 5 years ago

I think my mp3 file has some problem