XB-BOX - 🎵 音频切片(基础)
Slice audio to exact frames for video models — no manual math
- audio
- frame_count
- fps
The moment video models started eating audio, a new class of pain appeared: your voice track and your video frames have to agree to the frame, or the lips drift and the whole thing looks broken. XB_AudioSlicer exists so you never have to compute "how many seconds is 81 frames at 25fps" by hand again. You pick a file, set a start and end time, and it hands you back an AUDIO clip plus the exact frame count a video model will want to consume it as.
It's one of the quiet workhorses in XB_ToolBox, the big "beginner toolbox" pack that ships roughly 500 nodes aimed at making Wan/LTX-style video pipelines easier. Nothing here is flashy - which is exactly the point. It's the node you wire between a dialogue file and a sampler's segment_length so the timing just works.
How it works
The node reads an audio file out of ComfyUI's input directory, decodes it (the pack uses PyAV under the hood), and does three things worth knowing about:
- Downmixes to mono. Stereo becomes a single channel. For voice that's fine and saves a little memory.
- Clamps your times. If
end_timeruns past the end of the file, it quietly pulls back; if start and end collide it forces a minimum slice rather than erroring. - Snaps the frame count to the
4N+1rule. This is the clever bit. Video models like Wan want frame counts of the form1, 5, 9, 13…- a fixed residue that keeps the temporal structure aligned. The node rounds your rawduration × fpsto the nearest4N+1and pads or trims the audio samples so the physical waveform matches, so audio length and frame count never disagree.
That last step is the whole reason to reach for this over a plain crop. A raw crop at 25fps of 3.24 seconds is 81 frames if you're lucky and 80 if you're not; this node makes it deterministic.
The inputs that matter
- audio - a dropdown of every audio file (mp3, wav, flac, ogg, m4a, aac, opus, wma, webm) sitting in
ComfyUI/input. Drop your file there, refresh, pick it. - fps - default 25. Set it to match your video pipeline (24 for many LTX setups, 25 or 30 for broadcast-style).
- start_time / end_time - in seconds, step 0.01.
- duration_display - a read-only label showing the computed frame count in the UI.
The three outputs are audio (the sliced AUDIO), frame_count (an INT you can wire straight into a segment_length-style input), and fps (a passthrough FLOAT, handy for a frame-rate bus).
Installing
This comes in XB_ToolBox, so install once and the whole family shows up. Easiest via ComfyUI Manager - search XB_ToolBox and hit install - or:
cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
then restart ComfyUI. The audio slicer itself needs PyAV (pip install av if your environment lacks it; the pack lists it in requirements.txt).
Common issues
- File not in the dropdown - you dropped it in the wrong folder. It reads
ComfyUI/input, not your desktop. Restart ComfyUI after adding files. - "0 frames" output - you picked
none(the placeholder entry) or a file that failed to decode. Re-pick the file. - Audio sounds half-speed / stretched - that's usually the
4N+1snap plus an fps mismatch downstream. Confirm your sampler's fps matches what you set here.
One honest caveat: the base slicer has no waveform preview - for that you want the V1 variant, which adds a drag-to-select waveform window. Same slicing logic, nicer UI for finding your in/out points.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | COMBO | 1 options: none | |
| fps | FLOAT | 251–120 | — |
| start_time | FLOAT | 0.000–99999 | — |
| end_time | FLOAT | 10.000–99999 | — |
| duration_display | STRING | 0 帧 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| audio | AUDIO | — |
| frame_count | INT | — |
| fps | FLOAT | — |