// 获取当前视频截图
const videoDom=document.getElementById('uploadVideo')
// videoDom.setAttribute('crossOrigin','anonymous')//解决跨域报错问题,可以在video上加该标签
videoDom.pause()
const currentTime=videoDom.currentTime
const canvas=document.createElement('canvas')
canvas.width=videoDom.clientWidth
canvas.height=videoDom.clientHeight
canvas.getContext('2d').drawImage(videoDom,0,0,canvas.width,canvas.height)
const dataUrl=canvas.toDataURL('image/png')// 转base64
JS 截取视频某一帧图片 实现视频截图
最新推荐文章于 2024-07-26 11:41:15 发布