1

I have a video and a WebRTC audio stream and want to use Web Audio API to send the audio from the video to the Left channel, while the WebRTC to the right channel. So basically I'm doing:

video = document.getElementsByTagName("video")[0]
video.src = "http://link/to/my/video"
video.load()

audioContext = new AudioContext()
videoSourceL = audioContext.createMediaElementSource(video)
#create merger with 2 inputs, left (0) and right (1)
merger = audioContext.createChannelMerger(2)
merger.connect(audioContext.destination)

#now strange work around for WebRTC
audio = new Audio();
audio.muted = true
audio.srcObject = remoteStream
audioStreamR = audioContext.createMediaStreamSource(remoteStream)

# connect remote audio stream channel 0 to input 1 (right)
audioStreamR.connect(merger, 0, 1)

#connect video source channel 0 to input 0 (left)
videoSourceL.connect(merger, 0, 0)

The problem I have is that although the remote audio does go to the right channel (And is not audible in the Left), the audio from the video is also still slightly present in the right channel. So basically I have audio bleeding. The weird thing is that if I redirect both the remote stream and the video to the same channel, then the other channel has absolute silence.

Whereas if I had used an oscillator in place of the video audio, I would have a perfect separation. Any idea what I'm doing wrong?

EDIT: I also tried from the OS audio settings to turn off the left channel, and the audio bleeding to the right channel stopped (also tried this on a colleagues machine), so is this maybe a hardware/configuration issue?

ChrisGeo
  • 3,807
  • 13
  • 54
  • 92
  • Have you tried in different browsers? Is a local microphone involved? – jib Mar 07 '19 at 03:11
  • Yes I have the exact behavior in Firefox. The audio from the microphone is audible only on the recipient side as a WebRTC stream. – ChrisGeo Mar 07 '19 at 11:57

1 Answers1

0

Was a hardware issue after all, effect is not there with good headphones.

ChrisGeo
  • 3,807
  • 13
  • 54
  • 92