For Each runs a set of nodes once for every frame of an image sequence. The results come back as a new sequence, in frame order.
Use it to redraw, repaint, or restyle a clip frame by frame. To get several results from one node in a single run, use Number of results on the node instead. See Batch processing.
Set up a For Each loop
-
Select the nodes to repeat, right-click, and choose For Each. Or add For Each from the node menu, and drag the nodes inside it.
-
Connect an image sequence to the container's Frame Sequence input.
-
Inside the container, connect Frame to the first node. If a node needs the frame number, connect Count as well.
-
Connect the image output of the last node to Frame Result.
-
Connect the container's Frame Sequence output to the next node, such as Sequence to Video. A For Each container with nothing after it doesn't run: Run Graph does nothing and shows no message.
-
Run the graph. The results leave on the container's Frame Sequence output.
Examples
Draw every frame as a pencil sketch
A dancer's live-action clip becomes 72 pencil drawings, one for each frame. The style frame and the prompt sit outside the container, so they run once and feed every drawing.
Count tells each pass which frame it's on. Here, the frame number is joined into the prompt, so it's drawn on every sheet.
Seventy-two pencil drawings from one For Each loop
Repaint a clip in one saved look
Two seconds of live action become 48 watercolor frames. The saved look stays outside the container, so every frame matches it. The run took about twenty minutes.
Forty-eight watercolor frames, with the saved look kept outside the loop
Ports
|
Port |
Where |
What it does |
|---|---|---|
|
Frame Sequence |
Input |
The image sequence to loop over. |
|
Skip Failed Frames |
Input |
Connect a Boolean node set to True to keep going when a frame fails. |
|
Frame |
Inside |
The current frame. Connect it to the first node. |
|
Count |
Inside |
The frame number, starting at 1. |
|
Frame Result |
Inside |
Connect the image output of the last node here. |
|
Frame Sequence |
Output |
The results, in frame order. |
|
Unprocessed Frames |
Output |
The frames that weren't processed, so you can run them again. |
How For Each runs
What runs once, and what runs on every frame
Nodes outside the container run once, and every frame reuses their results. Nodes inside run on every frame. To run a node once or hold its result, put it outside the container and connect it in.
A frame of grouped nodes can't go inside a For Each container, and one container can't go inside another.
Run behavior
The container has its own run behavior: Run then Hold (the default), Run always, or Hold.
When a frame fails
To keep going when a frame fails, connect a Boolean node set to True to Skip Failed Frames. Otherwise, the first failed frame stops the run.
Either way, the frames already processed still leave on Frame Sequence. Frames that weren't processed leave on Unprocessed Frames, so you can run them again.
Try it on a short clip first
We recommend this order:
-
Run the loop on a short clip.
-
Check that the frames look right.
-
Run the whole clip.
Paid nodes inside a For Each container are charged for every frame. Before a run, Nodey asks you to confirm in the For Each can be costly dialog. Click Understood to go ahead.
Stop or bring back the cost question
To stop the question:
-
Tick Don't Ask Again.
-
Click Understood.
To bring it back:
-
Open Settings.
-
Find Warn About For Each Costs under General.
-
Click Reset.