如何从视频裁剪画布并保存为图像?

时间:2017-03-09 13:40:00

标签: video canvas

如何从视频裁剪画布并保存为图像? 我正在使用这个

function capture(){
var canvas = document.getElementById('canvas');
var video = document.getElementById('video');
canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight); }

和html是

<v ideo id="video" src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4" controls></video><br/>

<button onclick="capture()">Capture</button> <br/><br/>
<canvas class="input" id="canvas"></canvas> <br/><br/>

将图像作为画布获取。但现在如何保存为图像?我尝试使用Filesaver.js 但我不知道如何使用此代码从画布保存为图像。

var canvas = document.getElementById("my-canvas"), ctx == canvas.getContext("2d");
// draw to canvas...
canvas.toBlob(function(blob) {
saveAs(blob, "pretty image.png");
});

1 个答案:

答案 0 :(得分:0)

点击下载活动上写下以下代码:

if rising_edge(clk) then
  Y <= A / B;
  if B = 0 then
    err <= '1'; -- Synchronous control of `err`
  else
    err <= '0';
  end if;
end if;