Skip to content

Instantly share code, notes, and snippets.

@enobufs
Last active April 19, 2022 16:31
Show Gist options
  • Save enobufs/f4ea4d248289adc5a18e8d79c2e92684 to your computer and use it in GitHub Desktop.
Save enobufs/f4ea4d248289adc5a18e8d79c2e92684 to your computer and use it in GitHub Desktop.
MediaTrackSettings.echoCancellation Test
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<style>
html, body{
height: 100%;
width: 100%;
}
#video{
height: 300px;
width: 300px;
}
</style>
<script>
$(() => {
var constraints = {
audio: {
echoCancellationType: 'system',
echoCancellation: true,
noiseSuppression: true,
sampleRate:24000,
sampleSize:16,
channelCount:2,
volume:0.5
},
video: {
width:320,
height:240,
frameRate:{ideal:60, min:10}
}
}
navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
$('#video')[0].srcObject = stream;
let statusHtml = '';
stream.getTracks().forEach((track) => {
statusHtml = statusHtml + track.kind+":"+JSON.stringify(track.getSettings(), null, 2)+'<br>';
console.log('settings:', track.getSettings());
console.log('capabilities:', track.getCapabilities());
})
$('#status').html(statusHtml);
}).catch((err) => {
console.log(err);
});
});
</script>
</head>
<body>
<h1>Echo Cancellation Test</h1>
<p>Try changing values of echoCancellation, noiseSuppression properties in the code.</p>
<div>
<video id='video' autoplay='false' playsinline='false'></video>
<pre id='status'></pre>
</div>
</body>
</html>
@faryar76
Copy link

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment