Nodes/FxAi(凤希全能节点)/凤希AI - 视频分段加载
ComfyUI Node

凤希AI - 视频分段加载

Decode one segment at a time, never the whole film

By fxai666·Created 7 months ago·Updated about 20 hours ago· 47
凤希AI - 视频分段加载
  • 分段时长列表
  • 视频帧
  • 音频
  • 本段帧数
◄视频路径►
◄当前索引0►
◄起始帧0►

The half of the segment workflow that touches pixels

FxAiVideoSegmenterV1 only does arithmetic - it never opens the video. Something has to actually decode a chunk of frames, and the obvious approach (load the whole file, slice it) is exactly what kills long-video workflows. A four-minute 768p clip as a float32 tensor is tens of gigabytes of RAM before you've done anything to it.

FxAiVideoSegmentLoad (凤希AI - 视频分段加载) decodes only the requested segment, using ffmpeg with a seek and a frame limit, straight into a tensor. Put it inside a loop, give it the loop index, and the whole film never exists in memory.

How it works

Four steps. It re-probes the file for fps and dimensions (the segmenter and the loader share one utility module, so both use the same numbers). It rebuilds frame counts from the duration list with the same half-up rounding the segmenter used, so the seconds → frames round trip doesn't drift. It computes the start as 起始帧 + sum(counts before this index), clamped so a rounding-heavy last segment can't run past the end. Then it pipes ffmpeg raw rgb24 out for exactly that many frames, and pulls the matching audio span as float32 stereo at 44.1kHz with the same frame→time conversion.

One nice detail in that conversion: the seek time is nudged by 0.1ms past the frame boundary, because -ss picks the frame whose interval contains the timestamp - flush on the boundary and floating-point error puts two adjacent segments on the same frame. That kind of thing is why you use somebody's segmenter instead of writing your own.

It also broadcasts progress to the ComfyUI frontend for each segment ("segment 3 of 47"), so a long run tells you where it is.

Inputs and outputs

  • 视频路径 (STRING) - the segmenter's 视频路径 output. Relative to input/, or absolute if you insist.
  • 分段时长列表 (LIST) - must be wired; this is the 分段时长列表 output, in seconds.
  • 当前索引 (INT, from 0) - in a loop, this is the loop's index.
  • 起始帧 (INT, default 0) - the segmenter's 起始帧. This is the trim offset, not a per-segment start; the loader does the per-segment addition itself.

Outputs: 视频帧 (IMAGE, the decoded batch), 音频 (AUDIO, the same span), 本段帧数 (INT, the count actually decoded).

本段帧数 is not decoration - it's the honest answer when the plan and reality disagree, which they do on the final segment. Wire it into whatever writes the segment out rather than trusting the planned number.

How it slots into a loop

Segmenter → its 分段总数 into FxAiForLoopStart.total; its 分段时长列表, 视频路径 and 起始帧 into this node (the first two through loop slots if you want them carried); the loop's index into 当前索引; then frames → your pipeline → save → back to the loop end. Every iteration sees one segment and one only.

That's the whole architecture this pack is built around: segments as the unit of work, RAM proportional to a segment, not a film.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit

You also need ffmpeg and ffprobe on PATH - both decode paths here are subprocess pipes, not a Python ffmpeg binding. Verify with ffmpeg -version in the same shell environment that launches ComfyUI. No model files involved.

Where it bites

"疑似传入了帧数而不是秒数". The node refuses any list whose largest entry exceeds 600 seconds, on the theory that a four-digit number is a frame count, not a duration. It's right about 99% of the time. Make sure the list comes from the segmenter and not from a hand-built integer list.

Index out of range. 当前索引 is validated against the list length, so a loop that runs one iteration too long dies with a clear message rather than reading past the end. Count from 0, and let 分段总数 set the loop's total.

Forgetting 起始帧. It defaults to 0 and the graph won't complain - you just get a picture offset by exactly the seconds you trimmed off the front. If you used 跳过初始段 on the segmenter, wire the offset.

"这一段没解到帧". ffmpeg returned nothing: either the seek landed past the end of the file, or the file isn't readable by your ffmpeg build. The error carries the start frame and count, which is enough to tell which.

Frame rate disagreement. If the decoded count is short of the plan, the node logs it and moves on - usually a genuinely short final segment, occasionally a container whose stated rate doesn't match its frames. It doesn't try to be clever about duplicating frames.

Node missing from the menu. This pack registers each node in its own try/except and prints ❌[凤希AI] 节点加载失败 when an import fails - one missing node, no loud error. Read the console, restart, then debug.

Category凤希AI/视频

Inputs (4)

NameTypeDefaultDescription
视频路径STRING接「视频分段器V1」输出的视频路径(input 下的相对路径), 也可以手填完整路径或相对路径。
分段时长列表LIST—
当前索引INT0第几段,从 0 开始。接循环控制器逐次递增。
起始帧INT0分段器掐头后的起点帧,接「视频分段器V1」的「起始帧」。 没掐头就是 0。不接这个,跳过初始段之后画面会从第 0 帧切起。

Outputs (3)

NameTypeDescription
视频帧IMAGE—
音频AUDIO—
本段帧数INT—