<style>
The video {
Width: 500 px;
height:300px;
}
</style>
<body>
- & gt;
<script>
The function showFrame (event) {
Let scale=0.8, video=event. The target,
Canvas=document. The createElement method (" canvas ");//create a canvas
Canvas. Width=video. VideoWidth * scale;
Canvas. Height=video. VideoHeight * scale;
Canvas. GetContext (' 2 d) drawImage (video, 0, 0, canvas, width, canvas, height);
Try {
The console. The log (canvas. ToDataURL (" image/PNG "))
Document. The getElementById (" img "). src=https://bbs.csdn.net/topics/canvas.toDataURL (" image/PNG ");
Video. SetAttribute (" poster, "canvas. ToDataURL (" image/PNG"));
}
The catch (err) {
The console. The log (" Error: "+ err);
}
}
</script>