electron framework: record audio for input and output voice Ask Question


#1

I am developing an electron application to record input and output audio of the device.

Is there any way to do that?

Currently, I am able to record the input audio and for that, I am using navigator.mediaDevices.getUserMedia. I got to know that this API does not allow to record output audio.


#2

Hi @bsratqtx, you can record any stream (in and out) with a MediaRecorder… but why do you want to capture a stream that is already available for output in the first place?


#3

I want to develope an application which can record a complete incoming calls, the audio of caller and the receiver both.
Do you have some other idea to do that?


#4

Well how do you currently create a connection and consume the remote stream?


#5

For now I am not taking output audio from remote all I am doing is I plugged in the microphone and playing a mp3 on the laptop which will be treated as output audio and as a input audio I am speaking from the microphone. The microphone audio is getting recorded but the mp3 audio is not.


#6

In that case I’d suggest to first get the actual voice chat working before worrying about recording; e.g. using WebRTC you can directly feed the remote stream into a MediaRecorder:

remotePeerConnection.addEventListener('addstream', ({ stream }) => {
  const recorder = new MediaRecorder(stream)
  //...
})

If you do want to record your audio element that can be done too with captureStream() which you can then pass to a MediaRecorder, but that would seem like an unnecessary intermediary step to me…


#7

hi @m3g4p0p thanks for the quick responses.
Could you please help me to capture the speaker audio of the device if I plugged in the headphone/microphone.

I explored the api and get to know that we can use the remotePeerConnection to get the remote audio. So, like this is there any method to get the audio of the headphone/microphone speaker?


#8

No, this is not possible AFAIK. Did you try capturing the stream of your audio element though (see the above link)?

But again, in a real-world scenario it would make more sense to directly record the stream you’re feeding to the audio element, rather than feeding the stream to an audio element and then again capturing the stream of that element. TBH it sounds like you’re trying to find a workaround for something that isn’t even a problem…