Answers for "capture image from video element"

1

capture image from video element

const video = document.getElementById("video");

const canvas = document.createElement("canvas");
// scale the canvas accordingly
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
// draw the video at that frame
canvas.getContext('2d')
  .drawImage(video, 0, 0, canvas.width, canvas.height);
// convert it to a usable data URL
const dataURL = canvas.toDataURL();
Posted by: Guest on March-23-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language