I am trying to apply new constraints to the video track, but it doesn't work:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body onload="onLoad();">
<p id="res1"></p>
<p id="res2"></p>
<script>
async function onLoad() {
var opts1 = {audio: true, video: {advanced: [{ width: 1280, height: 960 },]}};
var stream = await navigator.mediaDevices.getUserMedia(opts1);
var cstr1 = stream.getVideoTracks()[0].getSettings();
document.getElementById("res1").innerHTML = cstr1.width + ", " + cstr1.height;
var opts2 = {audio: true, video: {advanced: [{ width: 640, height: 480 },]}};
await stream.getVideoTracks()[0].applyConstraints(opts2);
cstr2 = stream.getVideoTracks()[0].getSettings();
document.getElementById("res2").innerHTML = cstr2.width + ", " + cstr2.height;
}
</script>
</body>
</html>
I expect the answer "1280, 960" before applying the constraints and "640, 480" after. But I see "1280, 960" instead. Why? How can I apply it correctly?