0

I am using ffmpeg npm package in Node JS for processing my audio files. My application usecase is that there will be a meeting recording which will happen for every attendee who joins the meeting and his/her voice will be recorded and stored to S3. Any attendee can come to the meeting later. There will be one person who will start the recording for all the people and he will only stop recording for all.

This way the recording duration for every attendee will be slightly different. But we need a single audio file which will work as if discussion was happened between multiple attendees. I am using SOX npm package for mixing my all these audio files.

If the duration of any attendee is small then I am creating first a silence file and then concatenating that file to it.

ffprobe(processedFilesToAddSilence[index], { path: ffprobeStatic.path }, async function(err, info) {
          const duration = maxDuration - info.streams[0].duration;
            new ffmpeg({ source: '/dev/zero'})
              .inputFormat('s16le')
              .audioCodec('pcm_s16le')
              .withAudioCodec('libmp3lame')
              .withAudioFrequency(48000)
              .withAudioChannels(1)
              .toFormat('mp3')
              .withDuration(duration)
              .on('error', function(error) {
                console.log('An error occurred: ' + error.message);
              })
              .on('end', function() {
                new ffmpeg(silenceFiles[index])
                  .input(processedFilesToAddSilence[index])
                  .withAudioCodec('libmp3lame')
                  .withAudioFrequency(48000)
                  .withAudioChannels(1)
                  .toFormat('mp3')
                  .on('error', function(errr) {
                    console.log('An error occurred: ' + errr.message);
                    resolve('Wohoo!');
                  })
                  .on('end', function() {
                    console.log('Merging finished !');
                    resolve('Wohoo!');
                  })
                  .mergeToFile(finalProcessedFfmpegTempFileNames[index], '/tmp/dir');
                console.log('Processing finished !');
              })
              .saveToFile(silenceFiles[index]);
        });

But at the end I am getting a file where sound comes like it is echoed. I want an exact duration of silence file so that this problem can be resolved. If there is any other solution to my problem you can please tell that also. This is the link to my audio file after mixing 3 files of same content: https://sndup.net/472g

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.