Loading video frames to memory

i am making a video playing object which needs to have a very low latency when jumping frames, and playing directly from an ofVideoPlayer is too slow. what is the most effective way to load the video into memor? i.e. quick access to individual frames, while being able to load as much of the video as possible into memory.

the best way i have found so far is to loop through all the frames and store them in a vector<ofPixels>. that works well for a part of the video, but it runs out of memory before it loads the whole video into the vector. is there a more memory-efficient way to do this?

int numFrames = video.getTotalNumFrames();
vector<ofPixels> pixels;
pixels.resize(numFrames);
for (int idx = 0; idx < numFrames; idx++) {
    video.setFrame(idx);
    video.update();
    pixels[idx].setFromPixels(video.getPixels(), video.getWidth(), video.getHeight(), OF_IMAGE_COLOR);
}

I don’t have a solution, just some thoughts…
Did you try an uncompressed codec, like HAP ?
Did you try to save your video as images sequence, in separate files, on a SSD drive (best with RAID 0) ?

Did you try a 64 bit branch of OF? You can use a lot more memory.

Just a question: why not use nextFrame() instead of setFrame()?

EDIT: while pausing the video, that is. Wouldn’t that give more finegrained control?

So I tried the following, and it fits into RAM (yay for modern computers with crazylots of GB!), but the only frame that is loaded is the first. Is there any way to load the entire movie without having to play the whole thing in the draw loop first?

unsigned long nChannels = sourceMovie.getPixelsRef().getNumChannels();
unsigned long frameSize = w * h * nChannels;
unsigned long maxFrames = w * 2; // two screens deep
frames = vector<unsigned char>(frameSize * maxFrames);
for (unsigned long frameIdx = 0; frameIdx < maxFrames; frameIdx++){
    sourceMovie.nextFrame();
    while(!sourceMovie.isFrameNew()){
        sourceMovie.update();
    }
    unsigned char * pixels = sourceMovie.getPixels();
    unsigned long offset = frameIdx*frameSize;
    for (unsigned long i = 0; i < frameSize; i++){
        frames[i + offset] = pixels[i];
    }
}

ever find a solution to this?

I didn’t find any good solution to solve this. But what I did instead is that I used an addon called ofxHapPlayer ( https://github.com/bangnoise/ofxHapPlayer)
With this addon I was able to flip through all the frames in a long video in 60fps.