ComfyUI Node

分镜循环 · 成对提示词

ShotLoopPrompts is a JSON list of shots that hands your graph one pair at a time

By playboy-dongan·Created 23 days ago·Updated 23 days ago· 1
分镜循环 · 成对提示词
    • image_prompt
    • video_prompt
    • filename_prefix
    ◄shots_json[ { "image": "分镜1的图像提示词", "video": "分镜1的动作和运镜提示词" }, { "image": "分镜2的图像提示词", "video": "分镜2的动作和运镜提示词" }, { "image": "分镜3的图像提示词", "video": "分镜3的动作和运镜提示词" }, { "image": "分镜4的图像提示词", "video": "分镜4的动作和运镜提示词" }, { "image": "分镜5的图像提示词", "video": "分镜5的动作和运镜提示词" } ]►
    ◄shot_index0►
    ◄run_tokenmanual►

    A text box that behaves like a playlist

    If you write video in ComfyUI, you know the shape of the problem: a shot needs two prompts, not one. You describe the image - subject, framing, lighting - and then separately you describe the motion: camera push, orbit, how the hair moves. They belong together, and they live in two different CLIP text encodes, so keeping five shots straight means shuffling text between boxes.

    ShotLoopPrompts is the prompt source that fixes this. You give it one JSON array of shots, and it outputs the image prompt and the video prompt for one shot - the one you asked for via shot_index. Run the graph again with a different index and you get the next pair.

    Honestly: on its own it's a small utility. Its real job is being the first half of the pack's original two-node pair, where a partner node drives shot_index while a gallery collects the resulting videos. If you want the version that does everything in one place, SmartShotLoop is the newer unified node (0.2.0) and the one most people should install - it subclasses this node and adds the loop controls. This one is what the pack ships for the older 分镜循环组件.json sample and for graphs that prefer the prompt source and the driver to be separate.

    What it does per execution

    Read the source and there's almost nothing to it, which is the nice part: select() parses shots_json, range-checks shot_index against the array length, and returns three strings. Invalid JSON, an empty array, more than 100 items, a missing or blank image/video, or an out-of-range index all raise a clear error (分镜必须是包含 1–100 项的 JSON 数组, shot_index 超出分镜范围). Nothing about your images or model is touched.

    filename_prefix is built as shot_loop/<token>/shot_06 - a per-shot path with a two-digit shot number, which is exactly what you want feeding a save node so five runs don't overwrite the same file. The <token> comes from run_token, and it's sanitized first: anything that isn't alphanumeric, -, or _ is stripped, capped at 80 characters. The pack's own tests check that ../danger can't produce a .. in the path. So even though run_token looks like a free-text field, it's a namespacing folder, not something you should be hand-editing.

    There's one subtlety worth knowing, because it explains a behaviour you'd otherwise file as a bug. The node overrides IS_CHANGED to return float("NaN") - the standard ComfyUI idiom for "my output can never be cached," since NaN isn't equal to anything, including another NaN. Without it, re-submitting the exact same prompt text would let ComfyUI's cache skip the node and serve the previous shot. The trade-off is the general one: a never-cached node invalidates the cache for everything downstream of it, so this node makes your graph run for real every time.

    The fields

    shots_json is the only one that matters day to day. It's a multiline string holding a JSON array of 1–100 objects, each with a required image and video and an optional title:

    [
      {"title": "opening", "image": "wide shot, woman on the shore at dawn", "video": "slow push in, waves rolling"},
      {"title": "detail", "image": "macro of a shell on wet sand", "video": "camera drifts down, foam washes over"}
    ]
    

    title never reaches the model - it's a label for the gallery in the partner node. Then shot_index (0-based, capped at 99) picks the entry, and run_token namespaces the output folder. Outputs are image_prompt, video_prompt, and filename_prefix, all STRINGs.

    Wire image_prompt and video_prompt into your two text encodes and filename_prefix into your save node's prefix field. If your prompts currently live in node widgets, right-click and Convert widget to input first so there's a socket to connect.

    Install

    Same pack, same one-time install. In ComfyUI-Manager search comfyui-smart-shot-loop (publisher playboy-dongan, display name ComfyUI Smart Shot Loop · 智能分镜循环), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/playboy-dongan/ComfyUI-Smart-Shot-Loop.git
    

    No pip packages, no models - the project declares zero dependencies. Restart ComfyUI and refresh the browser tab. The node's display name in the menu is Chinese (分镜循环 · 成对提示词), so search ShotLoopPrompts if the English name doesn't turn up.

    Two things that trip people up

    Queue still runs it once. Running the graph normally executes this node at shot_index = 0, so you get shot 1's pair and then your pipeline stops. That's not broken; that's a single execution. The looping comes from the partner node's button, which rewrites shot_index and re-submits.

    If you pair it with the gallery node, both prompt outputs have to be wired into the graph that the gallery targets. The driver validates that image_prompt and video_prompt both reach the selected save node's upstream - skip one and the batch refuses to start rather than generating five identical videos.

    Bear in mind this is a very new pack (0.2.0, early October 2026) with no community write-ups yet, and its author is upfront that the frontend and the loop were tested against mocked APIs rather than a live GPU. The prompt-source half here is small enough that it's readable in full, which is the reassuring part.

    CategoryShot Loop / 分镜循环

    Inputs (3)

    NameTypeDefaultDescription
    shots_jsonSTRING[ { "image": "分镜1的图像提示词", "video": "分镜1的动作和运镜提示词" }, { "image": "分镜2的图像提示词", "video": "分镜2的动作和运镜提示词" }, { "image": "分镜3的图像提示词", "video": "分镜3的动作和运镜提示词" }, { "image": "分镜4的图像提示词", "video": "分镜4的动作和运镜提示词" }, { "image": "分镜5的图像提示词", "video": "分镜5的动作和运镜提示词" } ]—
    shot_indexINT00–99—
    run_tokenSTRINGmanual—

    Outputs (3)

    NameTypeDescription
    image_promptSTRING—
    video_promptSTRING—
    filename_prefixSTRING—