darbyjohnston / tlRender

tlRender is an open source library for building playback and review applications for visual effects, film, and animation.
BSD 3-Clause "New" or "Revised" License
193 stars 22 forks source link

Caching does not begin from the current frame when refreshing cache. #124

Closed ggarra13 closed 1 year ago

ggarra13 commented 1 year ago

On long movies or long .otio edits, with a cache setting set to Gigabytes (ie. a long ReadAhead / ReadBehind), when refreshing the cache by calling:

    io::Options options = player->getIOOptions();
    options["refresh"] = randomString();
    player->setIOOptions(options);

The caching does not begin from the current frame but begins from the beginning of the movie / edit, making it slow to interact with.

darbyjohnston commented 1 year ago

Is "refresh" something you added to your branch?

ggarra13 commented 1 year ago

No. I just added that to force the IOOptions to be different. I assumed you might have been doing a compare of, as usual:

Player::setIOOptions(const io::Options& value) { if (p.ioOptions == value) return; ...etc... }

If it is not needed, let me know.

ggarra13 commented 1 year ago

And yes, I am seeing that in current branch, when I call the refresh_cache_cb() in my code.

ggarra13 commented 1 year ago

I added the "refresh" = randomString() as I was getting the IOOptions from the player. So, that for example, the OpenEXR "Layer" option is not changed. I saw that you were doing:

player->setIOOptions({});

But that would reset the OpenEXR layer selection.

darbyjohnston commented 1 year ago

I checked in a change so the player now requests the current video frame first when caching, this should hopefully make skipping frames more interactive. I would also recommend not setting the cache read behind too high, it's just meant to keep a few frames for stepping back and forth.

Instead of setting the I/O options you can also use timeline::Player::clearCache() to clear the cache.

ggarra13 commented 1 year ago

Thanks. I think the main culprit was the ReadBehind. Once I left it at 0.4secs without trying to increase it due to the memory setting, the workflow became interactive.