Created
October 20, 2022 06:58
-
-
Save ThinhVu/d1fe813b67944e85418f85cba93e1b62 to your computer and use it in GitHub Desktop.
Save current frame of a video into an image
This file contains hidden or 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) { | |
var canvas = document.createElement("canvas"); | |
canvas.width = video.videoWidth; | |
canvas.height = video.videoHeight; | |
var canvasContext = canvas.getContext("2d"); | |
canvasContext.drawImage(video, 0, 0); | |
const image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); | |
window.location.href=image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment