标签:width VID click nap UNC logs canvas 保存 alc
通过js截取video窗口的一帧渲染到canvas。
如果需要保存为图片,只需将canvas保存为图片即可。
canvas保存为图片参考:https://www.cnblogs.com/dch0/p/11698982.html
<!DOCTYPE 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>
标签:width VID click nap UNC logs canvas 保存 alc
原文地址:https://www.cnblogs.com/dch0/p/12090268.html