Nodes/ComfyUI_FlashVSR/FlashVSR_SM_VideoTrimLoop
ComfyUI Node

FlashVSR_SM_VideoTrimLoop

Chop a long clip into pieces without leaving ComfyUI

By smthemex·Created about a year ago·Updated 8 days ago· 406
FlashVSR_SM_VideoTrimLoop
    • VIDEO
    • number
    • seed
    • filename
    • start_time
    ◄video_file▾►
    ◄split_length5.0►
    ◄seed0►
    ◄reset_bool0►

    The boring truth about video upscaling: the hard part is rarely the model, it's the length. A 90-second clip is 2,700 frames, and no consumer card holds that in VRAM in one pass. So you slice it and run the graph once per slice - exactly the tedium this node removes.

    Pick a video, say how many seconds you want per piece, and each time you queue the graph it hands you the next piece. It's a paginator for video. Small node, genuinely saves you a Premiere round-trip.

    What it is

    FlashVSR_SM_VideoTrimLoop sits at the front of the graph where a LoadVideo normally would. Its VIDEO output goes into GetVideoComponents (which splits into frames, fps and audio), and the frames feed FlashVSR_SM_KSampler's image. The rest of the chain is unchanged.

    It keeps an iteration counter keyed to the video's absolute path. Every time the node executes, the counter goes up by one, and the segment index is the counter modulo the number of segments - so it walks 1, 2, 3, … and then wraps back to 1. That wrap is deliberate: it means a long queue never runs out, and it also means a queue longer than your segment count will silently re-render segment 1 over its own output. Count your runs.

    The pack overrides the node's fingerprint so it re-executes on every queue rather than caching - that's what makes the counter advance - and it drops a quick MP4 preview of each segment into ComfyUI's temp folder so you can see the cut without opening a file browser.

    The inputs

    video_file is a dropdown of playable videos in ComfyUI/input, with an upload button - same behaviour as the core LoadVideo node. You do not pre-split anything; give it the whole file.

    split_length is the piece size in seconds, default 5.0, and it accepts fractions down to 0.1. Five seconds is a sane FlashVSR default: at 30fps that's 150 frames, more than one comfortable pass on 12–16GB. Drop to 2 or 3 if you're tight on VRAM.

    seed is a passthrough. Whatever you set here comes out the seed output, which is the point: wire it into the KSampler's seed and every segment in a batch gets a different seed instead of the same one, without you touching anything between queues.

    reset_bool is the optional one, and it's the escape hatch. Feed it a value of 1 or more and the counter for this file goes back to zero, so the next segment is the first one again. Handy when you've been clicking around debugging and lost track of where you are.

    The outputs

    VIDEO is the trimmed segment - the one you'll actually use. number is the raw iteration counter, useful as an index or a filename suffix. seed is the passthrough above. filename is the source file's base name, which is what you want to feed SaveVideo's prefix so segments don't all land on the same output name. start_time is the segment's offset in seconds from the beginning of the source, printed to console as well; that's your key for reassembling the pieces in order afterwards.

    Reassembly is not this node's job - you're on your own for concatenating, though ffmpeg's concat demuxer and a text file of the segment paths will do it in one line.

    Install

    Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/smthemex/ComfyUI_FlashVSR
    cd ComfyUI_FlashVSR && pip install -r requirements.txt
    

    Then restart, and put the video you want to upscale in ComfyUI/input. No model weights are needed for this node specifically; it's plain video plumbing. If you're installing the whole pack, the weights live in ComfyUI/models/FlashVSR and ComfyUI/models/vae - see the Model and Vae pages.

    How to actually run it

    Set your graph up, then work out how many segments you need - a 20-second clip cut into 5-second pieces is 4 - and set ComfyUI's batch count to that number rather than clicking Queue four times. The author's own note in the bundled workflow says the same thing: run the number of batches that matches your split.

    video: 20s, split_length: 5  ->  set "batch count" to 4  ->  segments 0-5, 5-10, 10-15, 15-20
    

    Troubleshooting

    It keeps giving me the first clip. Either a ComfyUI restart wiped the in-memory counter, or your queue is longer than the segment count and you're watching the wrap. Run once with reset_bool at 1, then set it back to 0.

    The video isn't in the dropdown. It has to be in ComfyUI/input; use the node's upload button if you don't want to copy files. Refresh after dropping a file in.

    Segments are a frame or two off from a clean cut. Trimming here is time-based against the container rather than frame-exact, so don't expect cuts on specific frames. Overshoot by a fraction of a second and trim the finished clip in an editor if you need exactness.

    The counter restarted after I moved the file. The counter is keyed on the video's absolute path, so re-uploading it under a new name, or pointing at a different copy, starts you at segment 1 again. Same file, same path, same place in the sequence.

    One queue of a 10-minute video. Each segment is a full diffusion pass; a batch count of 120 is an overnight job that starts over if it dies at segment 90. Run them in groups.

    CategoryFlashVSR

    Inputs (4)

    NameTypeDefaultDescription
    video_fileCOMBO选择完整视频文件,无需预先切分
    split_lengthFLOAT5.00.1–3600每次迭代输出的切分时长(秒)
    seedINT00–2147483647—
    reset_booloptINT0输入值 >= 1 时,迭代计数器归零(从头开始)

    Outputs (5)

    NameTypeDescription
    VIDEOVIDEO—
    numberNUMBER—
    seedINT—
    filenameSTRING—
    start_timeFLOAT—