凤希AI - 音频帧数计算器
The frame-count math that keeps audio and video from drifting apart
- 音频
- 生成帧数
Here's the silent killer in segment-by-segment video: audio is measured in seconds, but a video model works in frames, and video latents live on a fixed grid. If your first segment generates 120 frames for a 5.0-second clip but the next one generates 121 for the same 5.0 seconds, your audio and video slowly slide out of sync - imperceptible per segment, unwatchable by minute three. FxAIAudioFrameCalculate (凤希AI - 音频帧数计算器) exists so that never happens. Feed it an AUDIO segment and it tells you the exact number of frames to generate for it, rounded up to your model's frame grid.
How it works
The math is plain but the choice of defaults is where the pack does you a favor. It takes your audio, counts the samples, and divides by the sample rate to get real seconds. Multiply by 帧率 (fps, default 24) to get raw frames. Then it rounds that number up to the nearest multiple of 帧数对齐基数 (frame alignment base, default 8) - that's the LTX-style latent grid; most video VAEs expect frame counts on an 8-frame boundary. Finally it adds 过渡帧数 (transition frames, default 1).
That transition-frame add-on is the pack's loop-glue idea: each segment overlaps its neighbor by a frame or two so the stitched result has a hand-off frame to blend, instead of a hard cut. It's the same philosophy as the FxAiVideoGenerator series - every segment deliberately borrows a little from the next.
Inputs
音频- an AUDIO input, typically the segment you plan to generate against (e.g. the剪切音频output ofFxAIAudioSegmentLoad).帧率- int, default 24.帧数对齐基数- int, default 8. The model's frame grid; 8 is the safe LTX default, but if your model wants 16-frame batches, bump it.过渡帧数- int, default 1.
Output
One output: 生成帧数 (frames to generate), an INT. Feed it into whatever sampler/video node drives your segment generation so it knows exactly how long to run.
Install
Part of fxai-toolkit (凤希全能节点包), the MIT-licensed Chinese utility pack from author 凤希AI, built around making long video fit on modest VRAM by generating in chunks. Install via ComfyUI Manager (search "fxai") or:
cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit
# restart ComfyUI
The pack auto-installs soundfile and psutil. This node itself is pure math - no ffmpeg needed - but the nodes it typically pairs with (the segmenters) do use ffprobe, so keep ffmpeg on PATH anyway. No model downloads.
Gotchas
- It rounds up, always.
FxAiAudioSegmentLoad(its partner on the slicing side) rounds down per segment and reassigns the leftover to the last segment. If you wire them with mismatched帧数对齐基数- say 8 here and 16 there - the whole drift-fixing scheme quietly falls apart. - The output is the number of frames for one segment. In a loop, don't reuse it for every segment; each one needs its own calculation from its own audio, which is why this node sits inside the loop rather than once before it.
- Zero-length or silent audio yields a tiny frame count, not an error. That's usually a wiring problem upstream - check that the AUDIO socket is actually connected.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| 音频 | AUDIO | — | |
| 帧率 | INT | 24 | — |
| 帧数对齐基数 | INT | 8 | — |
| 过渡帧数 | INT | 1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 生成帧数 | INT | — |