Nodes/AM VFX Tools/AM Reverse Sequence
ComfyUI Node

AM Reverse Sequence

Play it backwards, masks included

By am-pipeline-prod·Created 4 months ago·Updated 3 months ago· 3
AM Reverse Sequence
  • image
  • mask
  • video
  • image
  • mask
  • video
show_previewtrue

Sometimes the shot needs to run backwards. AM Reverse Sequence flips the frame order of an IMAGE batch, a MASK batch, or a VIDEO stream - the kind of node that's one line of code and still gets reached for constantly once you work with sequences. Reverse a clip to loop it seamlessly, make a character walk back out of a room, or just build a ping-pong loop without re-rolling frames.

It's part of comfyui-am-vfx-tools ("AM VFX Tools" category), Adrian Meyer's 13-node VFX toolkit. The node's own description positions it as a drop-in replacement for KJNodes' Reverse Image Batch, with one upgrade: a VIDEO output socket, so the reversed sequence can feed the pack's lazy transform chain without materialising the batch at every node.

How it works

On the IMAGE side it's exactly what you'd hope: torch.flip along the time axis. Cheap, deterministic, no surprises. Peak RAM during the flip is about 2× the batch - the flip itself is a view, but the reverse output holds the whole batch in memory.

The VIDEO path is where the honest tradeoff lives. The node can't be lazy here - PyAV doesn't decode backward, so reversing a video requires pulling the source frames into memory, flipping the tensors, and wrapping them back into a VideoFromComponents. That means ~2× the source in RAM for the duration of the flip. What you get in exchange is a reversed VIDEO that downstream AM nodes (Reformat, Grade, OCIO, Image Write) can consume lazily, one frame at a time, without further full-batch materialisations. So: one unavoidable spike, then streaming.

Inputs and outputs

  • image - the batch to reverse.
  • mask - reversed in lockstep. Unwired, outputs zeros (the stock "nothing to inpaint" convention).
  • video - if wired, image and mask are ignored; it materialises, flips, and re-wraps.

Outputs: image (reversed, same shape/dtype), mask (reversed), and video (a zero-copy wrapper around the reversed batch). There's also a show_preview toggle, and it's cleverer than it looks: it shows the first frame of the reversed sequence, i.e. the last frame of the input - instant visual confirmation the reverse actually fired.

Installing it

Same as the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/am-pipeline-prod/comfyui-am-vfx-tools.git
cd comfyui-am-vfx-tools
pip install -r requirements.txt

Restart ComfyUI, or search comfyui-am-vfx-tools in ComfyUI Manager.

Where people get burned

The 2× RAM spike on the video path catches people who came for the streaming story. It's a one-time spike, not per-node - the win is that everything after the reverse streams. And remember the mask convention: if you reverse an RGB image with no mask wired, the mask output is zeros, which downstream reads as "fully opaque / nothing to inpaint." If you were counting on reversing alpha along with the frames, wire the mask in (or feed a 4-channel image).

CategoryAM VFX Tools

Inputs (4)

NameTypeDefaultDescription
show_previewBOOLEANtrueShow a thumbnail of the FIRST frame of the reversed sequence (= LAST frame of the input) on the node — visual confirmation the reverse fired.
imageoptIMAGEImage batch to reverse along the frame dimension. Cheap — `torch.flip` per the time axis. Peak RAM during the flip is 2× the batch.
maskoptMASKOptional MASK batch to reverse alongside the IMAGE. If unwired and IMAGE has no alpha, the output MASK is zeros (stock-ComfyUI 'nothing to inpaint' convention).
videooptVIDEOOptional VIDEO input. When wired, this node materialises the source via `get_components()` to access frames in random order, flips the in-memory tensors, and returns a fresh `VideoFromComponents`. Peak RAM during the flip is ~2× source — reverse can't be lazy because PyAV doesn't decode backward. The wrapped output IS consumable by downstream lazy AM chains. `image` and `mask` are ignored when `video` is wired. See invariant 28.

Outputs (3)

NameTypeDescription
imageIMAGEReversed image batch (same shape / dtype as input). RGB only.
maskMASKReversed mask batch (same shape / dtype as input mask). Zeros when no mask was wired and the source had no alpha.
videoVIDEOLazy-friendly VIDEO output — wraps the reversed IMAGE batch in a zero-copy `VideoFromComponents`. Downstream AM transforms can consume this lazily (one frame at a time) without further materialisations. None when no input is wired.