MiniMax H3 Aicg 自动分段切点
Cut a Long Video Into Pieces H3's Latent Grid Will Actually Accept
- selected_video
- segment_cuts
- segment_cuts_frames
- segment_count
- plan_summary
The job: chop a reference video into H3-sized chunks
One of the more interesting things you can do with H3 is whole-video replacement - take an existing clip, and regenerate it section by section with H3 while keeping the motion, pacing and audio timing. The MiniMax H3 Aicg 已选视频上下文 node does the heavy lifting, but it needs to know where to cut, and it wants those cuts in a format it accepts, aligned to a grid H3's temporal compression can handle.
Hand-counting frame numbers for a two-minute clip is nobody's idea of a good afternoon. MiniMax H3 Aicg 自动分段切点 (AICG3D_H3SegmentCuts) does the arithmetic: give it a target shot length and the video, and it spits out a cut list you paste downstream.
The alignment part is the actual value. H3's latent compresses time in steps of 17 frames - roughly 0.71 seconds at 24fps. Cut at an arbitrary frame and the Motion Context node rejects your list with a "cuts cannot be aligned" error. This node snaps the cuts to that grid for you.
How it works
segment_seconds(default 5.0) - target length per shot.snap_to_latent_grid(default on) - snap cuts to the 17-frame grid. With snapping on, the real shot length lands on the nearest multiple, and the node tells you when snapping moved it more than 10% off your target.max_segments(default 120) - a guard. Without it, a 3-second target on a long clip produces hundreds of segments, and each one is a render. That's hours of GPU time you didn't mean to commit to.fallback_seconds(default 120) - total duration to plan against when no video is connected.selected_video(VIDEO, optional) - connect the clip and the node uses its real frame count instead, resampled to H3's 24fps timeline first.
Four outputs:
segment_cuts- the cut points in seconds, comma-separated. This is the string you paste into the selected-video context node'ssegment_cutsfield, withsegment_modeset totime_cuts.segment_cuts_frames- the same cuts as frame numbers, for anything that wants them.segment_count- how many shots this produces.plan_summary- a human-readable breakdown: total frames, actual per-shot lengths, and whether the grid snapped. It also prints to the console.
Two details from the code worth knowing. The cuts are always computed on H3's own timeline (24fps) because the selected-video context resamples reference footage to that rate anyway - so a 30fps source gives you cuts that look odd in frames but are correct in seconds. And if the clip is too short to split, you get zero cuts, a count of 1, and an empty segment_cuts - which means "don't segment", exactly what the context node does by default.
Wiring
Load Video ──> AICG3D_H3SegmentCuts ──> segment_cuts (STRING, seconds)
│
└─> 已选视频上下文 (segment_mode = time_cuts)
└─> 分段采样 ──> 分段解码
Install
cd ComfyUI/custom_nodes
git clone https://github.com/JGRFW/comfyui-AICG3D
Restart and Ctrl+F5. Manager install: Registry search AICG3D / 短剧工作台 / MiniMax H3. The whole plugin's pip dependency list is imageio-ffmpeg, so:
python -m pip install imageio-ffmpeg
in ComfyUI's Python covers it - needed because the long-video combiner shells out to ffmpeg, not because of this node.
Traps
Turning snapping off while using latent continuity. The tooltip is explicit: if you keep the default latent_guide continuity mode, snap_to_latent_grid must stay on or your cuts get rejected. Only disable it if you've switched to a pixel-level guide, and expect the node to tell you so in the summary line.
Length you asked for vs length you got. Ask for 5 seconds with snapping on and you'll get something near 4.96 or 5.10 - a whole number of 17-frame blocks. If your edit needs exact 5-second beats, cut on the timeline and re-join; the latent grid refuses to negotiate.
Pasting the frames output into the seconds field. They look similar (comma-separated integers) and only one of them is what the context node wants. segment_cuts is seconds; segment_cuts_frames is frames.
Segment count you didn't notice. Each segment is a full render. Check plan_summary before you queue, and keep max_segments low enough to catch a typo - a segment_seconds of 0.5 on a three-minute clip is 360 renders.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| segment_seconds | FLOAT | 5.00.2–60 | 每段多长(秒)。长视频替换就靠它切段;开了网格对齐后实际段长会贴到最近的 17 帧(约 0.71 秒)倍数。 |
| snap_to_latent_grid | BOOLEAN | true | 把切点对齐到 Context Segment 的 17 帧网格。连续性用默认的 latent_guide 时必须开着,否则会被拒绝。 |
| max_segments | INT | 1201–2000 | 段数上限,防止切得过碎把时间和显存拉爆。 |
| fallback_seconds | FLOAT | 1201–3600 | 没接 selected_video 时按这个总时长算切点(接了视频就忽略它)。切点统一按 24fps 时间轴换算。 |
| selected_videoopt | VIDEO | 待替换的长视频;接上后按它的真实帧数换算切点。 |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| segment_cuts | STRING | — |
| segment_cuts_frames | STRING | — |
| segment_count | INT | — |
| plan_summary | STRING | — |