[英]Make screenshot from a video with canvas overlay
i've a html5 video with a pair of sibling canvas that make some effects over it. 我有一个带有一对兄弟画布的html5视频,在上面有一些效果。 The structure is something like this:
结构是这样的:
<div id="container_video">
<video id="video1" width="450" height="340" preload="auto"></video>
<canvas id="overlay" width="450" height="340"></canvas>
<canvas id="webgl" width="450" height="340"></canvas>
</div>
I wanna make a snapshot from the whole scene, the video with the overlays canvas. 我想从整个场景(带有覆盖画布的视频)中制作快照。 I only reach to capture the video, but not the whole scene.
我只能捕捉视频,而不能捕捉整个场景。
What can i do? 我能做什么?
Thanks. 谢谢。
<video id="video1" width="450" height="340" preload="auto"></video>
<canvas id="overlay" width="450" height="340"></canvas>
<canvas id="webgl" width="450" height="340"></canvas>
canvas = document.createElement("canvas");
canvas.width = 450;
canvas.height = 340;
var ctx = canvas.getContext("2d");
var vid = document.getElementById("video1");
var over = document.getElementById("overlay");
var gl = document.getElementById("webgl");
ctx.drawImage(vid,0,0);
ctx.drawImage(over,0,0);
ctx.drawImage(gl,0,0);
// canvas now contains the 3 elements as one image.
You will have to check the video has loaded and at the seek pos you want. 您将必须检查视频是否已加载,并在所需的搜索位置。
@Blindman67 it doesn't work @ Blindman67它不起作用
If i do this, i've the next error: 如果执行此操作,则出现下一个错误:
TypeError: canvas.getContext is not a function in
var ctx = canvas.getContext("2d");
I try on the other way, like this: 我尝试另一种方式,如下所示:
var ctx_full = document.getElementById("canvas_full");
ctx = ctx_full.getContext("2d");
var vid = document.getElementById("video1");
var over = document.getElementById("overlay");
var gl = document.getElementById("webgl");
ctx.drawImage(vid,0,0);
ctx.drawImage(over,0,0);
ctx.drawImage(gl,0,0);
And then i've the error "TypeError: 然后我出现了错误“ TypeError:
Argument 1 of CanvasRenderingContext2D.drawImage could not be converted to any of: HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap. in ctx.drawImage(vid,0,0);
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.