Nodes/ComfyUI_Swwan/Preview Animation (Swwan)
ComfyUI Node

Preview Animation (Swwan)

Actually watch your batch before you save it

By aining2022·Created 10 months ago·Updated about 18 hours ago· 33
Preview Animation (Swwan)
  • images
  • masks
    ◄fps8.00►

    What it's for

    An IMAGE batch in ComfyUI's default preview is a stack of stills in a viewer you have to click through. For anything animated - an AnimateDiff scroll, a Wan video render, a batch you just padded with hold frames - that's useless. You need to see it move.

    Preview Animation takes a batch, writes an animated WebP into ComfyUI's temp directory, and hands the frontend an animated preview. It's an output node with no outputs at all - RETURN_TYPES is empty - so you can't chain it, and that's fine. It's a monitor, not a stage in the pipeline. KJNodes' PreviewAnimation, in the pack under Swwan/Advanced/IO.

    How it works

    One required widget: fps, a float, default 8.0, and it's the only thing you must set. Two optional inputs: images (an IMAGE batch) and masks (a MASK batch).

    • Images only - each frame is converted to an 8-bit PIL image and saved as an animated WebP, duration = 1000/fps milliseconds per frame, lossy at quality 50, with a _temp_xxxxx filename prefix in the temp folder.
    • Images and masks together - the masks get composited onto their frames as alpha before encoding. So you get a preview of the actual matte, per frame, which is a genuinely useful way to eyeball whether a mask chain is drifting.
    • Masks only - each mask becomes a greyscale frame. That's your "is the mask flickering frame to frame?" check, and it catches problems a single-frame preview never will.

    Anything else prints PreviewAnimation: No images or masks provided and returns an empty UI payload, so a battery of these with nothing wired is silent rather than fatal.

    Two practical notes. The fps widget is a preview rate: it's how fast the browser plays it back, and it doesn't have to match the rate you'll save at. And the file lands in the temp directory, so it's disposable and gets swept - if you want to keep the motion as a file you can hand someone, encode it deliberately with a video or animated-WebP saver rather than trusting this preview.

    This is a small node that solves the review step of the KB's image I/O story: ComfyUI gives you pixels and metadata, but a batch is a poor preview medium, and video review in the browser is what the tooling expects.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/aining2022/ComfyUI_Swwan
    cd ComfyUI_Swwan
    python -m pip install -r requirements.txt
    

    Restart ComfyUI and hard-refresh the tab - the reload matters more than usual here, because this node depends on one of the pack's five frontend scripts (web/js/swwan_preview.js) to render the animated payload. If you see a static first frame and the animation flag never arrives, a stale browser cache is the first suspect.

    Requirements are Pillow, numpy, OpenCV, scipy and scikit-image, with torch from your ComfyUI environment. No models, no GPU work.

    Common issues

    No frame appears in the UI. Stale frontend. Hard-refresh (Ctrl/Cmd-Shift-R), and if the console shows a 404 under /extensions/ComfyUI_Swwan/, the pack's scripts aren't being served - restart the server.

    No images or masks provided in the console. Nothing is connected. Optional inputs on an output node are easy to leave dangling, especially when you duplicated the node.

    The animation plays at the wrong speed. fps is the playback rate of the preview, not of your source. Set it to whatever makes the motion readable; nothing downstream inherits it.

    Only one frame is previewed. A one-frame batch is reported as non-animated, correctly. Check upstream - a batch node may have collapsed it.

    A mask preview is inverted relative to what you expected. Remember that this composites the mask as alpha, so white in the mask means opaque. Behind a Load Image node, whose mask is 1 - alpha, that's a flip away from intuition.

    CategorySwwan/Advanced/IO

    Inputs (3)

    NameTypeDefaultDescription
    fpsFLOAT8.000.01–1000—
    imagesoptIMAGE—
    masksoptMASK—

    Outputs (0)

    No outputs