Hello,
I’m looking for a way to attach a post-processing to each frame of a video, and to do this as fast as the disk can deliver the fames (going to next frame as soon as the previous one is done).
I have made quite unsuccessful attempts with “player.nextFrame()”, rising the CPU usage up to 600%…
The most elegant version is to pause the video before making the post-processing, then un-pause it:
player.update();
player.setPaused(true);
player.update();
if (player.getCurrentFrame() != last_frame) {
... // post-processing
ofPixels hiResPixels;
saved_frame.readToPixels(hiResPixels);
ofSaveImage(hiResPixels, ss.str());
}
player.setPaused(false);
This implies that I have to wait for the next frame to arrive, even the process is faster than the video frame rate.
The other issue is the lack of precision: I missed several frames, due to the value returned by getCurrentFrame()…
Is there a way to attach a callback to the video player, independent of the main loop?
I’m on linux…
Thanks in advance!