获取视频截图

webHYT / 2023-05-31 / 原文

1、使用canvas对video元素进行截图

function  getVideoFrame(video){
 const canvas = document.createElement("canvas");
 canvas.width = video.videoWidth;
 canvas.height =video.videoHeight;
 canvas.getContext("2d").drawImage(video, 0, 0);
 return canvas.toDataURL("image/png");
}