canvas截取视频第一帧

var cut = function() {
    let canvas = document.createElement("canvas");//创建画布
    canvas.width = video.videoWidth * scale;
    canvas.height = video.videoHeight * scale;//设定宽高比
    canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);//将视频此刻帧数画入画布
    let img = document.createElement("img");
    img.src = canvas.toDataURL("image/png");
    Dom.appendChild(img);//写入到Dom
};
video.addEventListener('loadeddata',cut);//在视频帧数已加载时执行截取

你可能感兴趣的:(canvas截取视频第一帧)