Reputation: 15
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.
Upvotes: 1
Views: 2200
Reputation: 748
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
Upvotes: 1