'WebRTC getting error, I cant find that problem

It seems to be all are okay but I am having error. Can't find the error where it coming from! Hope anyone can help me here please https://gabrieltanner.org/blog/webrtc-video-broadcast

The error is Uncaught SyntaxError:

Identifier 'video' has already been declared

Broadcast.js:

const peerConnections = {};
const config = {
      iceServers: [
        { 
          "urls": "stun:stun.l.google.com:19302",
        },
        // { 
        //   "urls": "turn:TURN_IP?transport=tcp",
        //   "username": "TURN_USERNAME",
        //   "credential": "TURN_CREDENTIALS"
        // }
      ]
    };
    
const socket = io.connect(window.location.origin);
const video = document.querySelector('video');
const constraints = {
    video: {facingMode: "user"}
};
    
navigator.mediaDevices
    .getDisplayMedia(constraints)
    .then(stream => {
        video.srcObject = stream;
        socket.emit("broadcaster");
    })
    .catch(error => console.error(error));
    
    
socket.on("watcher", id => {
      const peerConnection = new RTCPeerConnection(config);
      peerConnections[id] = peerConnection;
    
      let stream = video.srcObject;
      stream.getTracks().forEach(track => peerConnection.addTrack(track, stream));
    
      peerConnection.onicecandidate = event => {
        if (event.candidate) {
          socket.emit("candidate", id, event.candidate);
        }
      };
    
      peerConnection
        .createOffer()
        .then(sdp => peerConnection.setLocalDescription(sdp))
        .then(() => {
          socket.emit("offer", id, peerConnection.localDescription);
        });
});
    
socket.on("answer", (id, description) => {
      peerConnections[id].setRemoteDescription(description);
});
    
socket.on("candidate", (id, candidate) => {
      peerConnections[id].addIceCandidate(new RTCIceCandidate(candidate));
});
    
    
socket.on("disconnectPeer", id => {
      peerConnections[id].close();
      delete peerConnections[id];
});
    
window.onunload = window.onbeforeunload = () => {
      socket.close();
};


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source