JSFiddle - React, Tailwind, and code Playground
by Joe Cisneros
HTML
<video id="video" src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4" controls></video><br/>
<button onclick="capture()">Capture</button> <br/><br/>
<canvas id="canvas"></canvas> <br/><br/>
<!--<button onclick="save()">Save</button> <br/><br/>-->
JavaScript
function capture(){
var canvas = document.getElementById('canvas');
var video = document.getElementById('video');
canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
}
$(function() {
capture();
});
/*
Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
(bc inside iframe, but we can still save the image by right-clicking on the generated canevas)
function save(){
var canvas = document.getElementById('canvas');
return canvas.toDataURL("image/png");
}
*/