Nodes/ComfyUI_StreamingT2V/PromptTravelIndex
ComfyUI Node

PromptTravelIndex

The little node that answers 'which prompt is running at frame N?'

By chaojie·Created 2 years ago·Updated 2 years ago· 36
PromptTravelIndex
    • STRING
    prompt
    index0

    PromptTravelIndex is a tiny decoder that turns a prompt schedule plus a frame number into one prompt: the prompt that should be active at that frame. It exists for one feature, prompt travel - the trick where a long video's subject or scene gradually changes as the generation progresses. The pack's cyclist demo (wf_prompttravel.json) is built on it, and the name is exactly what it does.

    Prompt travel is easy to describe and fiddly to build. You have a 200-frame video and you want frames 0–60 to be a cyclist, frames 90–140 to be the same cyclist crossing a bridge, frames 160+ to be him at night. Rather than retyping prompts at each extension step, you keep a schedule - "at frame X, use prompt Y" - and ask, at every chunk, which prompt is current. That lookup is this node's entire job.

    How it works

    You give it a prompt string that is a JSON object body - the keys are frame indices, the values are the prompts. It wraps your string in braces, runs json.loads on it, and walks the keys to find the value whose key is the largest one that's still ≤ your index. If the index has run past the last key, it clamps and returns the final prompt. So "0":"a cat running on the street", "100":"a dog chasing the cat" with index 60 returns the cat prompt; index 120 returns the dog prompt.

    Inputs and outputs

    Only two inputs, both worth knowing:

    • prompt - the schedule, as a JSON object body: "0":"first prompt", "100":"second prompt". Note the quotes around keys and values; it has to parse as JSON.
    • index - the frame you're asking about, an INT defaulting to 0.

    The single output is the selected STRING prompt. In the cyclist workflow it feeds the CLIP encoders and the pack's StreamingT2VRunLongStepVidXTendPipelinePromptTravel run node, so the graph never has to hardcode which prompt is "current" - it just computes it from the frame count, which the workflow tracks as it loops.

    Installing it

    Part of the ComfyUI_StreamingT2V pack, so install the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/chaojie/ComfyUI_StreamingT2V
    

    or use ComfyUI Manager (search StreamingT2V), then restart. The pack pulls a big dependency list (pytorch-lightning, diffusers, modelscope, xformers...) even though this node itself only needs the standard library's json.

    Where people get burned

    Malformed JSON. It's not a fuzzy text parser - if you forget a quote or add a trailing comma, the node throws and kills the whole workflow. Keep the schedule strict JSON and you're fine. The other gotcha is subtler: the default index is 0, and if your schedule's first key is 0 that's correct, but if your schedule starts at key 48 and something passes index 0, you get the empty string back. When in doubt, start your schedule at key 0. Beyond that, it's a lookup table with a JSON front door - the most predictable node in this pack.

    CategoryStreamingT2V

    Inputs (2)

    NameTypeDefaultDescription
    promptSTRING
    indexINT0

    Outputs (1)

    NameTypeDescription
    STRINGSTRING