Nodes/ComfyUI-VideoOverlayFFmpeg/String to Alignment (字符串转对齐数据)
ComfyUI Node

String to Alignment (字符串转对齐数据)

Paste a transcript JSON and get subtitle-ready alignment data

By GuardSkill·Created 10 months ago·Updated 9 months ago· 0
String to Alignment (字符串转对齐数据)
    • alignment
    alignment_string[]

    String2AlignmentNode is the inverse of its pack-mate Alignment2StringNode: you give it a JSON string describing subtitle segments and it hands back a whisper_alignment object that the video nodes can actually consume. It exists for one practical reason - sometimes you don't have a Whisper node in your graph, but you do have a transcript with timestamps sitting in a file or an editor. Instead of installing a transcription pipeline just to get subtitles, you paste the JSON here and wire the output straight into VideoOverlayWithSubtitlesNode.

    That pairing is the whole point: the overlay node's alignment input wants whisper_alignment, and this node is the on-ramp for anyone who's not running a transcription node upstream.

    How it works

    The input alignment_string is a multiline STRING field (default "[]"). The node parses it with json.loads and, if the result is a list, returns it as the whisper_alignment output. The segment format is the same one the rest of the pack uses:

    [
      { "value": "Your caption line here.", "start": 0.0, "end": 4.86 }
    ]
    

    Empty or whitespace-only input returns an empty list. Malformed JSON doesn't raise - it logs a [String2Alignment] JSON 解析错误 warning in the console and returns []. That's friendly but easy to miss, so if you paste something in and get no subtitles at the other end, the console is the first place to look.

    Because Alignment2StringNode pretty-prints with indent=2, you can round-trip: serialize alignment data to a string, hand-edit the timestamps or cut a line, then feed it back through this node. It's the cheapest way to nudge a caption's timing without re-running a model.

    Inputs, outputs, and the one gotcha

    One required input (alignment_string, multiline) and one output (alignment, type whisper_alignment). The only real trap is silent failure: if your JSON is wrong, you get no error in the graph UI, just a console warning and empty captions. Validate your JSON before pasting - or paste it through a text node you can see first.

    Installing it

    It ships inside GuardSkill/ComfyUI-VideoOverlayFFmpeg, so it arrives with the rest of the pack. ComfyUI Manager, search "ComfyUI-VideoOverlayFFmpeg", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GuardSkill/ComfyUI-VideoOverlayFFmpeg
    cd ComfyUI-VideoOverlayFFmpeg
    pip install -r requirement.txt
    

    Restart, and it's under the "whisper" category alongside Alignment2StringNode. No models, no ffmpeg involved in this node (though its sibling overlay nodes do want a system ffmpeg on your PATH). A tiny tool, but it's the difference between "I have a transcript" and "I have burned-in subtitles."

    Categorywhisper

    Inputs (1)

    NameTypeDefaultDescription
    alignment_stringSTRING[]

    Outputs (1)

    NameTypeDescription
    alignmentwhisper_alignment