Cache a whole movie at loadtime?

Hi there,

A movie file in, loading a small file with about 60 frames.
I want to cache it.

I use a Cache TOP, and multiple Cache Select TOPs

How to cache the whole movie at the launchtime and then stop to play it ?
I grab the number of frames, updates (with expressions) all I need to update (cache size etc).

But it seems that if I trim it (Hold or black), of course, it doesn’t seem to cycle but it fills the Cache with the black frame etc etc. I lost the cache.

Is there a straightforward way ? or should I script something to make the movie go to the n frame, cache, etc etc looping this.?

Have you looked at the examples for the Cache TOP under Help->Operators Snippets already?
The one called “pre-fill” is what you are after I think.

You can also increase the Pre Read Size to 60 in Movie File In TOP. This will cache it on the CPU side, allowing for quick seeking, but not using up so much GPU memory.

1 Like

Hello @nettoyeur, yes I checked it already.

The thing is, the Movie File In keeps playing. I can stop it, of course.
But if I want my process to be automated, I miss something.

What I do:
I put exactly the same network:
Movie File In TOP → Cache TOP with prefill with the right cache size.

I start the patch, it fills the cache (by reading the file) and then I want to stop it. How can I do that ?
Of course, the trim panel option with Hold instead of Cycle doesn’t help as it will fill / over feed the cache with blank frames.

I’ll end by putting a timer, the patch starts, the movie play a couple of times, the timer (5s after) stop the play. why not.
But I’m sure I miss something

The prefill function is at first a bit weird to get your head around. I’ll try to explain this to the best of my knowledge.
First it needs the me.time.frame expression in some parameter expression in any node upstream to function. (see the example in Op Snippets) . If you pulse the prefill button on the cache TOP, what it does, it cooks all nodes upstream of the Cache TOP with a varying me.time.frame value until the 100 frames in the Cache TOP are filled. This is a bit weird as you don’t “see” it happening. This also means any black or transparent end frames will not show up in the cache TOP.

Next to that, TD is a pull-based system. This means normally any node in TD only cooks if something or someone is asking for its data. In simple terms any node which contributes to the visual output in perform mode, or any node on which you have set the viewer panel “on” in Designer Mode (as that also means you are asking for its data). More info on that here: Cook - Derivative
This means the MOvie File In TOP will not cook/play anymore when 1) the Cache TOP is filled, and 2) you are not looking at its viewer pane anymore. You can check that this is really True by zooming out a level, and middle clicking the COMP in which your Movie File IN TOP is. You’ll see it’s not cooking anymore.

1 Like

thanks a lot.
I understand it well now.

it doesn’t really work precisely here.
If I push the pulse for prefill, and try to travel the cache with the downstream cache select, it only show one picture.

Of course, I switched off the play especially because frames are so big that it hang the system.

I think I need to find another way

You’ll need to enable play otherwise you don’t get all the frames. Perhaps you can share your example via a Dropbox link so we can take a look at it.

sure I can, but I exactly copy paste the one in snippet.
carefully checked the specify index setup and me.time.frame expression is running (well, when I select the movie file in)

problem: my movie is 7210 x 4005, 30 frames.
I want to cache these 30 frames.

if I start with play, the thing hang up.

yes it doesn’t work. I don’t say the system doesn’t, but here it doesn’t

my network is very simple: same as snippet.
in order not to hang the machine, i let play switched on BUT disabled the viewer of the node.
I start touchdesigner load the toe, ok. I pulse prefill (I’d automate it later)

it does something.
the cache seems to fill (even if I have only 27 frames, I put the cache size to 100 as in the example)… cache seems to fill a bit. and the fps drop down to 9.

when I change the cache index… hung system… 2 fps… etc.

my movie is H264 encoded

Maybe I should encode the movie differently and/or change the whole concept.

Actually I have these 7210x4005 frames (static) which I’m cropping/travelling into. this is the concept of my project.

but maybe that is just impossible to do here even with my 64Gb rtx2080 super machine.

I could try to back up to 27 movie file in, maybe.
switching them on demand,
but as I’m fading in.out at each transition, that’s not easy to modify everything here