devowlio / node-lame

LAME is an open-source encoder that encodes and decodes audio to the MP3 file format. For all MP3 needs a Node.js wrapper of the full LAME command line.
Other
82 stars 9 forks source link

unsupported audio format with buffers #9

Closed tobq closed 5 years ago

tobq commented 6 years ago
var { Lame } = require("node-lame"),
    fs = require("fs"),
    encoder = new Lame({
        output: "buffer",
        bitrate: 128,
        "mark-as-copyrighted": true,
    }).setBuffer(fs.readFileSync("....mp3"));

encoder.encode().then(function () {
    console.log(">>>>>>>>>>>>>>>>>>>>>", encoder.getBuffer())
}).catch(function (err) {
    console.log(err)
})


Error: lame: Warning: unsupported audio format
Can't init infile ...

No matter what type of buffer /file I use, I get this error.

jankarres commented 6 years ago

Have you installed lame on your computer and is it accessible via "lame" in the console, as described in the readme?

tobq commented 6 years ago

yes.

tobq commented 6 years ago

It works when working with a reach stream, but not with the buffer.

jankarres commented 6 years ago

I apologize for my late feedback. Have you found a solution yet?

fs.readFileSync("....mp3") returns <string> | <Buffer>. Please check with instanceof which type you get back?

jankarres commented 5 years ago

Closed due to no response.

malay44 commented 1 year ago

i am getting the same error but i am reading buffer from req.file.buffer. and it returns me the buffer only.