Created
October 29, 2022 15:58
-
-
Save blluv/40dc91fe522f38eb1e3d49a73985722e to your computer and use it in GitHub Desktop.
capture_video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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