5
我試圖從視頻中捕獲一幀並使用HTML5在畫布中繪製它,但下面的代碼不起作用。當我點擊開始按鈕畫布充滿了黑色HTML5 drawimage從視頻到畫布
<video src="video2.mp4" autoplay="true" type="video/mp4" width="300" height="200" id="vid">
</video>
<canvas id="cvs"> </canvas>
<button onclick="start()">Start</button>
<script>
var video=document.getElementById("vid");
var cvs=document.getElementById("cvs");
function start(){
cvs.getContext("2d").drawImage(video, 0, 0, 300,200);
}
</script>