Skip to content

Instantly share code, notes, and snippets.

@blluv
Created October 29, 2022 15:58
Show Gist options
  • Save blluv/40dc91fe522f38eb1e3d49a73985722e to your computer and use it in GitHub Desktop.
Save blluv/40dc91fe522f38eb1e3d49a73985722e to your computer and use it in GitHub Desktop.
capture_video
function captureVideo(video) {
const canvas = document.createElement("canvas");
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
const ctx = canvas.getContext("2d");
ctx.drawImage(video, 0, 0);
const url = canvas.toDataURL('image/png');
const a = document.createElement("a");
a.href = url;
a.download = String(new Date().getTime()) + ".png";
a.click()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment