We can follow the below steps to
Higher Video Resolution: Improved the resolution of the video feed by specified the width and height properties.
Canvas Size: Made the canvas element (<canvas>) has the same dimensions as the video feed to avoid any scaling issues. You can set the canvas size dynamically based on the video feed size:
canvas.width = videoStream.getVideoTracks()[0].getSettings().width;
canvas.height = videoStream.getVideoTracks()[0].getSettings().height;
Image Quality Parameter: When converting the canvas image to a data URL,adjusted the image quality by specifying a quality parameter between 0 and 1.
A higher value will result in better quality but larger file size. In the example above, 0.9 is used as a reasonable compromise between quality and size.
