Framerate manipulation to sync a buffer

hi all,

i am trying to setup a kind of video sampler, which buffers frames into a vector of ofImage.

when in record mode, in every update cycle, i push a new ofImage from my cam in my vector.

when in play mode, in every update cycle, i update the buffer to increment the progress, to have the next frame to draw.

the problem is that my cam is at 30fps, my app should run at 60fps, so when i draw the buffer, it displays two times faster.

here is the code that update the progress variable of the buffer:

void ofxVideoBuffers::update()
{
//cout<<"progress"<<progress<<endl;
if(canStartLoop == true)
{
    if (!isFinished())
    {
        if(!buffer.empty() && progress <= buffer.size()-1)
        {
            if (ofGetFrameNum() % 1 == 0)
            {
                progress++;
            }
        }

what is the cleanest way to fix that? should i try to implement a kind of timer to draw every two updatecycle or so?
i think there should be a simple test to update the progress var when

it seems not too hard to fix, but i don’t know what is the “cleanest” way to do it.

thanks in advance,

hi,

i’ m auto-answering :smile:
as i said, my cam runs at 30fps and the app at 60fps.
so i when i update my buffers every frame, i update them 60 times when i should update them only 30 times.

updating my buffers every two frames seems to fix the playback issue…

i think the better way would grab the app framerate, the cam framerate and update the buffers every appfps/camfps, does this seems good?