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

recieve buffer from client and store it as a mp3 file in server #17

Closed Archer-Thane closed 4 years ago

Archer-Thane commented 4 years ago

hey guys, awesome project! I try to recieve data from microphone of a client, convert it to array buffer in client side, send it through socket connection, recieve it server side, decode the buffer which is recieved, and save it as a file. but the problem is that when I recieve the new buffer, previous mp3 file will destroy and new decoded file will "replace" instead of append. here is my code (I write just server side here since I feel client side is not useful. If needed, just let me know): socket.on('transmitFile', function (data) { const decoder = new Lame({ "output": "demo.mp3" }).setBuffer(data); decoder.decode() .then(() => {}) .catch((error) => {}); }); when I open the folder which demo.mp3 is live in, I see that the size of this file (and obviously its content) is changing. how can I append it instead of rewrite it? thanks a lot

jankarres commented 4 years ago

Thanks for your request. If I summarize it correctly, after converting the WAV file into an MP3 file, you want to append one MP3 file to another.

Both LAME and node-lame can only convert files but not edit them (cut, append, prepend...). To merge two MP3 files, you can e.g. use audioconcat.