Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Storing frames from large video [Memory issue]

Hey guys,

I'm investigating how I can process video frames in bulk. Once I have my frames, I intend to just greyscale them and reconstruct the video. But what I'll add more to the process once this is achieved. Below is what I currently have

cv::Mat currentFrame;
std::vector<cv::Mat> frames;
cv::VideoCapture capture("../Clips/myFilm.avi");

int totalFrameCount = capture.get(CV_CAP_PROP_FRAME_COUNT);

for (int i = 0; i < totalFrameCount ; i++)
    capture >> currentFrame;
    frames.push_back(currentFrame.clone()); //Push our frame into a vector

This works when the video is small, but with larger ones I run out of memory. I don't know how to effectively free up memory in this scenario. On one hand, I can scale down the images in size before adding them, but that just pushes the problem further along when extremely high frame counts are involved.

Could anyone recommend me alternative designs that can handle long video files?

Thanks in advance.