Nodes/kubakub nodes/kubakub timecode filename prefix
ComfyUI Node

kubakub timecode filename prefix

Clip names that sort themselves by song position — timecode filename prefix

By kubakubkub·Created about a month ago·Updated 2 days ago· 10
kubakub timecode filename prefix
    • filename_prefix
    • timecode
    • frame
    ◄base_prefixclip►
    ◄seconds0.000►
    ◄fps25.000►
    ◄separator_►

    Twenty clips of a show, all called clip_00001.png, and no idea which one belongs to the chorus. That's the problem this node solves, and it's a small one until you're in Resolve at 1am trying to find the bar the visuals change on.

    It takes a base name and a start time in seconds and gives you back a filename prefix that is the timecode: clip_00-12-00. Twelve seconds into the song, at frame 0. Which, as it happens, sorts perfectly in a folder - every file lands in show order because the timecode leading digits are the sort key. That's the whole trick, and it's the only reason the node exists.

    Inputs

    base_prefix (default clip) is the start of the name. Call it what the project is called.

    seconds (default 0) is where this clip starts in the song or show. If you're driving a batch, this is the field you wire - it's a FLOAT with a 0.001 step, so frame-accurate starts are fine.

    fps (default 25) is the clip's frame rate. It's used to convert seconds into frames, and to work out the last part of the timecode. The maths is frame-first: it converts your start into a total frame count, then splits it, so you don't accumulate rounding error across a long list of clips. Frames themselves are counted against the rounded integer fps - sensible, since a frame is a discrete thing whatever your float says.

    separator (default _) is what goes between the name and the timecode. The default gives clip_00-12-00. Note the hyphens inside the timecode: colons are illegal in filenames on Windows, so mm-ss-ff it is, and it happens to sort identically to a proper timecode.

    One quirk you should know before it surprises you: there are no hours. Minutes just keep counting - 90 minutes into a show gives you 90-00-00, not 01-30-00. That's still chronological when sorted, which is the point, so don't go filing a bug.

    Outputs

    filename_prefix is the full string, base_prefix + separator + timecode, and it's the one you use: link it into any save node's filename_prefix. It behaves like a normal prefix, so Save Image will happily append its own counter after it.

    timecode is just the mm-ss-ff part, 00-12-00. Useful for burn-in nodes, text overlays, or a column in a shot list.

    frame is the start as a frame number - seconds × fps, rounded. That's the number you feed a generator that counts frames rather than seconds, or the one you stick in a spreadsheet when the editor asks where each clip starts.

    Nothing here depends on audio or video models; it's string arithmetic and it costs nothing to run. Wire it in even if you're exporting stills - the 3am problem isn't specific to video.

    Pairing it with the trim node

    The kubakub trim-to-exact-duration node (same pack, one menu group over) can move a clip's start when it wraps or clamps against the end of a track, and it reports where the clip actually starts on actual_start_seconds. Feed that into seconds here and your filenames stay honest - the file is named for where the clip really is in the song, not where you hoped it would be. It's the kind of small correctness that saves an hour of confusion later.

    Installing

    ComfyUI Manager → search kubakub nodes → install → restart. Or:

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

    ComfyUI 0.37.0 or newer; the requirements file adds opencv-python-headless if you don't have an OpenCV build already. It sits in the pack's utils group, which is the one group nothing else depends on - so it's the least interesting corner of a pack that's mostly projection mapping for buildings. Which is fair: a node that names files well is the sort of thing you notice only when it's absent.

    Categorykubakub/utils

    Inputs (4)

    NameTypeDefaultDescription
    base_prefixSTRINGclipThe start of the file name; the timecode is added after it.
    secondsFLOAT0.0000–86400Where the clip starts in the song or show, in seconds.
    fpsFLOAT25.0001–240Frames per second of the clip; the last part of the timecode counts frames at this rate.
    separatorSTRING_The text between the name and the timecode.

    Outputs (3)

    NameTypeDescription
    filename_prefixSTRINGThe name with the timecode, e.g. clip_00-12-00; link it into a save node's filename_prefix.
    timecodeSTRINGThe start as minutes-seconds-frames, e.g. 00-12-00 (sorts by time in a folder).
    frameINTThe start as a frame number: seconds x fps, rounded.