<video autoplay="true" id="video"><video>
<script>
video = document.getElementById("video");
if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices
.getUserMedia({ video: true })
.then(function(stream) {
video.srcObject = stream;
})
.catch(function(error) {
console.log("Something went wrong!");
});
}
<script>