user image

Mohamed Aboelfotoh
Published in : 2022-02-13

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!


Shilpa Date : 2022-02-26

Best answers


Best answers


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 }); mediaElementSource.connect(mediaStreamDest);});console.log([0]);

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 Date : 2022-08-12

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

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Vanilla JavaScript Next & prev Navigation
Publish date: 2022-02-22 | Comments: 1

Tag: Javascript

Required to convert Obj {} to Arr [] from key-value pairs using javascript
Publish date: 2022-03-06 | Comments: 2

Tag: Javascript

Coping plain text into form bug.
Publish date: 2022-02-11 | Comments: 1

Tag: Javascript

How do I check if an array includes a value in JavaScript?
Publish date: 2022-02-13 | Comments: 2

Tag: Javascript

Simple HTML date picker is showing not showing calendar icon!
Publish date: 2022-03-01 | Comments: 2

Tag: Javascript

Javascript: Filtering arrays by it properties?
Publish date: 2022-03-05 | Comments: 1

Tag: Javascript

JavaScript variable for Changing CSS Height
Publish date: 2022-02-12 | Comments: 1

Tag: Javascript