Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid echo and noise in javascript for webrtc

I am trying to implement a webrtc-based chat room. And I encountered the following problems in laptop. Without connecting to any other peer, just use getUserMedia(), I can get local video stream.

When I unmuted the <video>, echo happened.

Then I wear headphones, and found there is a continued noise. And I can hear my voice clearly.

I tried to turn down the volume, but it doesn't work.

Thanks in advance.

like image 778
Zhenguo Yang Avatar asked Aug 23 '13 15:08

Zhenguo Yang


People also ask

How do I get rid of echo in Webrtc?

getAudioStreams()[0]. enabled = false or localMediaStream. getVideoStreams()[0]. enabled = false to keep the sound going but disable the video stream.

How does echo cancellation work?

When it determines that the signal being sent out is the same signal that came in, it electronically cancels it so that the signal does not transmit back to the talker's loudspeakers, thus canceling the echo.


2 Answers

Make sure that you are muting the local <video> element if you have it in the DOM:

<video id="vid1" autoplay="true" muted="muted"></video> 

See this post on the discuss-webrtc mailing list for more details and the WebRTC samples.

like image 79
tomtheengineer Avatar answered Oct 03 '22 12:10

tomtheengineer


Do the followings:

1) In localVideo do the this:

localVideo.volume = 0;

localVideo.muted = 0;

2) Do same for the remoteVideo also:

remoteVideo.volume = 0;

remoteVideo.muted = 0;

like image 30
ArunDhwaj IIITH Avatar answered Oct 03 '22 13:10

ArunDhwaj IIITH