标签:contain one int image test wim img interval tin
截取视频当前播放画面,直接上源码。
<body>
<div class="container">
<video id="test" width="500" height="400" >
<source src="test.mp4" type="video/mp4">
</video>
</div>
<canvas height="400" width="500" id="canvas2" style="border:1px solid #000;margin: 50px;"></canvas>
<canvas height="400" width="500" id="canvas1" style="border:1px solid #000;margin: 50px;display: none;"></canvas>
<button type="button" onclick="drawImg()">click</button>
<script>
var video = document.getElementById(‘test‘);
var canvas1 = document.getElementById(‘canvas1‘);
var canvas2 = document.getElementById(‘canvas2‘);
var context1 = canvas1.getContext(‘2d‘);
var context2 = canvas2.getContext(‘2d‘);
function drawVideo() {
context1.drawImage(video,0,0,video.width,video.height);
}
function drawImg() {
context2.drawImage(canvas1,0,0,canvas1.width,canvas1.height)
}
video.play();
setInterval(drawVideo,100);
</script>
</body>
标签:contain one int image test wim img interval tin
原文地址:http://www.cnblogs.com/lillian0106/p/6925323.html