Mohamed Aboelfotoh

13 Feb 2022

How to get audio input and audio output as one stream?


I'm familiar with the MediaStream Recording API, however after doing some research, I'm not sure if I can use it to collect both input and output in JavaScript applications.

Basically, I'd like to record both my microphone and the audio that I get (basically the audio which comes from the other user mic).

Any assistance in pointing me in the correct path would be greatly appreciated!



26 Feb 2022


You may do it by the following code, (Using MediaStream Recording API approach)

var audioContext = new AudioContext();
var mediaStreamDest = new MediaStreamAudioDestinationNode(audioContext);
document.querySelectorAll("audio").forEach((e) => {
 var mediaElementSource = new MediaElementAudioSourceNode(audioContext, { mediaElement: e });

The above line, given in the console log will get the first audio track from your MediaStream. 


After that, it will mix up audio streams into one stream.


Shivesh Singh

12 Aug 2022

Hi Aboelfotoh, were you able to collect audio output? If yes could you please throw me some pointers how did you do it?

© 2023 Copyrights reserved for