Using canvas to grab pixel data from page
If I have a QT video on a page (where QT is a requirement that can't be changed) how can I grab the pixel data of the current frame that is being shown with canvas? I am aware that this is p开发者_StackOverflow社区ossible with getImage(videoElement, .....)
but I am looking for a solution that uses QT.
If getting the pixel data is not possible then is it possible to take a screenshot of the page using canvas and trim it perhaps?
Or am I going about this the wrong way and don't need to use canvas at all?
This is not possible with canvas. The function you are referring to has nothing to do with canvas, it has to do with the video element. The video element returns a picture that the canvas can use, and the QT object (or embed) does not.
Can you rely on java being available on the client? If so, you could use an offscreen java applet (using the quicktime for java libraries) to talk with javascript and your quicktime plugin to get at pixel data for a given frame. This solution requires loading the movie into the quicktime plugin AND into the applet. See http://processing.org/reference/libraries/video/index.html for a simplified api.
This is not a graceful solution. I don't like it. Just brainstorming.
Another idea is to pre-process the quicktime movie, and keep pixel data on your server. Ajax the correct frame's data when your page needs its. Depending on your videos' compression, this might be a good idea because getting accurate pixel data for every frame could be difficult because of keyframes.
This example on Mozilla: https://developer.mozilla.org/En/Manipulating_video_using_canvas
uses the getImageData()
function on the context object to do a chromakey replacement in a video.
精彩评论