1

The Question:

Can I use Javascript to mix multiple audio files into one audio?

For example, I have a long people voice and a short background voice, and I need to get mixed audio which the background voice will play until people voice finish.

Is there any way that I achieve this with Javascript?

What I do:

I trying some audio third library like Tone.js and Howler.js, but still can't have any progress

If someone knows this, I will be very grateful, thinks.

luohe
  • 15
  • 6

1 Answers1

1

ffmpeg.js meets your needs. This library provides FFmpeg builds ported to JavaScript


For browers:

Play two audios

Listen to the end event of previous audio, and play next audio.

Ensure audios are loaded in advance and check if there is a blank frame where the two audios are connected.

Another way, play the second audio a few millseconds early.

Concat two audios

Use AudioContext API to concat two audio buffers. Refer to Web Audio API append/concatenate different AudioBuffers and play them as one song

lry
  • 728
  • 3
  • 7
  • thanks for answering my question, but in this situation, I want to deal with audio in the browser without any server, is ffmpeg.js can do this? – luohe Jul 02 '20 at 03:59