I would like to get the raw data (TypedArray or something) from video element and manipulate them with JavaScript.
Currently I create a new canvas, draw the video into canvas and then get the image data.
ctx.drawImage(myVideo);
var data = ctx.getImageData(0, 0, w, h).data;
It works fine, but it drains a CPU (putting the video to canvas and copying back from canvas) and it creates a lot of garbage (about 50 MB each second). Is there any other simpler solution? It would be great if I could pass my own buffer to getImageData(...).
BTW. drawing video with WebGL and loading it back from GPU is not any faster :( http://jsperf.com/getting-raw-data-from-video
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…