js截取video标签图片
通过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>
相关推荐
ShoppingChen 2020-06-25
WebVincent 2020-06-06
行吟阁 2020-04-10
爱好HtmlCssJs 2020-01-18
冰蝶 2020-01-08
Jym 2012-07-05
tumobi 2016-12-08
一点一刻 2013-09-17
HandsomeHong 2010-08-13
Charliewolf 2019-11-10
WenFY的CSDN 2019-10-24
89510194 2019-10-22
nercon 2019-10-20
行吟阁 2019-10-22
zhangli 2014-11-12
jadechen00 2014-11-08