drawVideo(video) {
return new Promise((res, rej) => {
const canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d')
canvas.width = video.width
canvas.height = video.height
ctx.drawImage(video, 0, 0, canvas.width, canvas.height)
canvas.toBlob(bolb => {
res({ bolb, url: URL.createObjectURL(bolb) })
})
document.body.appendChild(canvas)
})
},
getVideoPic(url, time = 0) {
return new Promise((res, rej) => {
const video = document.createElement('video')
video.currentTime = time
video.muted = true
video.autoplay = true
video.oncanplay = async () => {
const frame = await drawVideo(video)
res(frame)
}
video.src = URL.createObjectURL(url)
})
},