简体   繁体   English

声音 webRTC android 中的回声和噪音

[英]Echo and noise in sound webRTC android

I am working on webRTC i am doing live stream between two android devices on local network it is working pretty fine for me except the sound quality issue there is noise and echo in sound.我正在开发 webRTC 我正在本地网络上的两个 Android 设备之间进行直播,它对我来说工作得很好,除了音质问题,声音中有噪音和回声。 If i use hands-free on one end it gets better but i don't want to use hands-free.如果我在一端使用免提,它会变得更好,但我不想使用免提。

So how can i improve the sound quality, what techniques are there to improve the sound quality.那么我怎样才能提高音质,有什么技巧可以提高音质。 It also said the webRTC has echo cancellation functionality built in if it's than why echo is still there.它还说 webRTC 内置了回声消除功能,如果这不是回声仍然存在的原因。

You can try to add special audio constraints when you are creating audio source.您可以在创建音频源时尝试添加特殊的音频约束。 It should looks like:它应该看起来像:

MediaConstraints audioConstraints = new MediaConstraints();
audioConstarints.mandatory.add(new MediaConstraints.KeyValuePair("googNoiseSuppression", "true"));
audioConstarints.mandatory.add(new MediaConstraints.KeyValuePair("googEchoCancellation", "true"));

There are a lot of media constraints related to audio features and I suggest to try different combinations of them, full list can be found here https://chromium.googlesource.com/external/webrtc/+/master/talk/app/webrtc/mediaconstraintsinterface.cc有很多与音频功能相关的媒体限制,我建议尝试它们的不同组合,完整列表可以在这里找到https://chromium.googlesource.com/external/webrtc/+/master/talk/app/webrtc /mediaconstraintsinterface.cc

I guess you are experiencing the Larsen effect, the 2 audio outputs being replayed by both microphones, creating endless audio loops.我猜您正在体验 Larsen 效果,两个麦克风都重放了 2 个音频输出,从而产生了无限的音频循环。 There is not much you can do against this if both devices are in the same room, but indeed browsers have echo cancellation options you can activate this way (not sure they are by default):如果两个设备都在同一个房间里,你就没有什么可以做的了,但浏览器确实有回声消除选项,你可以通过这种方式激活(不确定它们是默认的):

if (window.chrome) {
    audioConstraints = {
        mandatory: {
            echoCancellation: true
        }
    }
} else {
    audioConstraints = {
        echoCancellation: true
    }
}
var constraints = {video: videoConstraints, audio: audioConstraints};
navigator.getUserMedia(constraints, userMediaSuccess, userMediaError);

Also, mute the local video, users obviously don't need it.另外,将本地视频静音,用户显然不需要它。

What's happening is that you are playing your own local audio back to yourself.发生的事情是您正在播放自己的本地音频。 This creates a feedback loop between your microphone and speakers.这会在您的麦克风和扬声器之间创建一个反馈回路。 That's why it kinda sounds better when you have the hands-free device.这就是为什么当您拥有免提设备时听起来会更好的原因。 You can remove the local audio by modifying the stream of getUserMedia():您可以通过修改 getUserMedia() 的流来移除本地音频:

var constraints = {video: true, audio: true};
getUserMedia(constraints, function(stream){
    var videoOnly = new MediaStream(stream.getVideoTracks());
}, errorHandler);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM