R
R
Roman Andreevich2021-08-18 15:19:54
Audio
Roman Andreevich, 2021-08-18 15:19:54

How to merge multiple audio files into one and encode to mp3 in NodeJs?

Colleagues, good day. maybe someone will tell you, probably already something is missing. The bottom line is this, there are several mp3, aac files and a couple more audio formats at the input. you need to do 2 operations with them on Nodejs, firstly combine them into one, and secondly, convert them to mp3. Sobsna here.

In the browser, as I understand it, all this is done. Tell me if anyone has come across.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Pankov, 2021-08-18
@trapwalker

google towards ffmpeg

R
Rostislav, 2021-08-19
@rostikowb

https://www.npmjs.com/package/fluent-ffmpeg
And an example is something like this

const mergeProc = ffmpeg()
            .on('start', () => {
              console.log('Start merging' );
            })
            .on('end', () => {
              streams.forEach(({recordPath}) => {
                fs.unlinkSync(recordPath);
              })
              console.log('Merge end. You can play ' );
            });


          audioPathArr.forEach((recordPath) => {
            mergeProc.addInput(recordPath)
          });

          mergeProc.mergeToFile(VIDEO_OUTPUT_FILE)
            .on('error', function(err) {
              console.log('Error ' + err.message);
            })
            .on('end', function() {
              console.log('Finished!');
            });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question