js截取video标签图片
2021-05-07 08:30
标签:width VID click nap UNC logs canvas 保存 alc 通过js截取video窗口的一帧渲染到canvas。 如果需要保存为图片,只需将canvas保存为图片即可。 canvas保存为图片参考:https://www.cnblogs.com/dch0/p/11698982.html js截取video标签图片 标签:width VID click nap UNC logs canvas 保存 alc 原文地址:https://www.cnblogs.com/dch0/p/12090268.htmlDOCTYPE html>
html>
head>
meta charset="utf-8">
title>title>
style>
#localvideo{
width: 500px;
}
#localcanvas{
width: 500px;
}
style>
head>
body>
video id="localvideo" autoplay="autoplay">
source src="http://img.ksbbs.com/asset/Mon_1703/eb048d7839442d0.mp4">source>
video>
canvas id="localcanvas" width="1920" height="1080">canvas>
br />
button id="snapbtn">截取button>
body>
script>
var video = document.getElementById("localvideo");
var snapbtn = document.getElementById("snapbtn");
var canvas = document.getElementById("localcanvas");
var ctx = canvas.getContext("2d");
snapbtn.onclick = function(){
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
}
script>
html>
上一篇:css在360浏览器的兼容问题
下一篇:https搭建(自签名证书)