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 });

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.


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

Check if div have touch another div
Publish date: 2022-03-02 | 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

Method refactoring to avoid to many npe checks
Publish date: 2022-03-05 | Comments: 0

Tag: Javascript

javascript: Uncaught TypeError: undefined is not a function
Publish date: 2022-03-02 | Comments: 2

Tag: Javascript

What is the use of package-lock JSON file?
Publish date: 2022-02-11 | Comments: 3

Tag: Javascript

jquery undefined function
Publish date: 2022-02-28 | Comments: 1

Tag: Javascript