I'm trying to extract frames from a video, and it's working fine. But when i try to extract videos longer than 1 minutes i got
RangeError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': Out of memory at ImageData creation
i've extracted 1100 frames just fine, that's around 1 minute video with 24fps. Is there any limit when extracting frames from a video at once?
here's how i extracted those frames
this.video.getFrames(this.file, this.totalFrame, VideoToFramesMethod.totalFrames).then((frames) => {
frames.forEach((frame, i) => {
let img = document.createElement('img');
var canvas = document.createElement('canvas');
canvas.width = frame.width;
canvas.height = frame.height;
canvas.getContext('2d').putImageData(frame, 0, 0);
img.src = canvas.toDataURL('image/jpeg');
this.listOfImages.push({
id: i,
name: 'Frame ' + i,
src: img.src
});
});
this.addCheckboxes();
this.loading = false;
this.playVideo = true;
this.poster = this.listOfImages[0];
});
EDIT
What i need from images that have been extracted is, later the user can draw a points on to the images to determine some object, i use fabricjs for this, but i don't manipulate the images just add new image (which is fabricjs canvas) on top of that image. you can try it here https://bory-cam.web.app
And after that, my algorithm can track the movement of the object inside the points. Also i need to able to show each frame. My first is works, but it's too expensive to memory. So i tried this solution but it really slow. I wanna try this solution using webcodecs but i can't make it work with angular