简体   繁体   English

JavaScript 将视频帧绘制到画布上

[英]JavaScript Draw Frame of Video to Canvas

I am making a timeline using javascript and a canvas element.我正在使用 javascript 和画布元素制作时间线。 Typically, when the event on the timeline has an image associated to it, I use to following code to draw the image on the canvas:通常,当时间轴上的事件具有与之关联的图像时,我使用以下代码在画布上绘制图像:

var img = new Image();
img.src = 'image file name';
context.drawImage(img, 0, 0);

However, occasionally the 'image file name' is not actually an image, it's a video.但是,有时'image file name'实际上不是图像,而是视频。 In this case, I would just like to draw a frame of the video on the canvas.在这种情况下,我只想在画布上绘制视频的一帧。 It could be any frame.它可以是任何框架。 However, I am unsure of how to do this.但是,我不确定如何执行此操作。

i do not know (i am not web developer , i am android developer ) it is good or bed idea working with canvas for timeline but i think you should not use canvas .我不知道(我不是 Web 开发人员,我是 android 开发人员)使用画布作为时间线是好的还是不错的主意,但我认为您不应该使用画布。 but i have find a video which can help you in this scenario in this video you can see that you can put image or video according your need in timeline here is the link .但是我在这个视频中找到了一个可以帮助您解决这种情况的视频,您可以看到您可以根据需要在时间轴中放置图像或视频,这里是链接

NOTE : -笔记 : -

i do not own this channel or video or do not have any relation with firm .我不拥有此频道或视频或与公司没有任何关系。

Thank you .谢谢你 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM