Painter Audio Cut
Cut Audio to Wan's 4N+1 Frame Grid Without Doing the Math Yourself
- audio
- trimmed_audio
- total_frame
Your Wan 2.1 clip comes out 121 frames long, your soundtrack is three minutes, and the model wants audio that lands on a specific frame count. That mismatch is the entire reason this node exists. PainterAudioCut is a frame-based audio trimmer that slices your audio to a start/end point, optionally pads it with silence on either end, and then forces the total length onto Wan's 4N+1 frame grid - so the audio actually lines up with the video instead of drifting or getting rejected.
It comes from a small pack by 绘画小子 (a Chinese video-generation blogger who goes by princepainter on GitHub). It's a one-node pack, no models, no API, no dependencies beyond what ComfyUI already ships. Don't overthink the reputation question: this is a hobbyist utility, not an ecosystem player, and that's fine.
Why the 4N+1 thing exists
Wan's 3D causal VAE compresses time by roughly 4x, so valid decoded video lengths come out as 4N+1 frames - 81, 121, 125, 129, 161, and so on. That's why a clip you asked for as 120 frames often comes back 121, or why your carefully-trimmed music finishes a hair too early. The same constraint applies to the audio that conditions the generation. PainterAudioCut handles it so you don't have to count latents.
How it works
The node takes a standard ComfyUI AUDIO tensor (waveform plus sample rate - the same format any audio-loading node outputs) and does the math in your video's frame rate. Samples per frame is just sample_rate / frame_rate, so at 30fps and 44.1kHz, one frame is 1470 samples. It slices audio[..., start_sample:end_sample], prepends and appends silence if you asked for it, then rounds the total frame count up to the nearest 4N+1, padding with silence (or truncating) to hit it exactly.
The inputs that matter
There are only five, and none of them are in seconds - everything is frame counts at your chosen frame_rate. That's the thing beginners trip on. start_frame and end_frame define the slice of your source audio; set end_frame - start_frame (plus head/tail silence) to roughly your target video length. head_silence_frames and tail_silence_frames shift where the audible part starts and ends - handy when you want the music to kick in a second after the shot starts. frame_rate should match your video's fps exactly; it's a float, so 29.97 won't crash it.
Outputs and where they go
trimmed_audio(AUDIO) - the aligned audio tensor. In a Wan 2.1 audio-to-video workflow it feeds the audio conditioning path. If you're just adding sound to an I2V/T2V clip, you can attach it to your output video via VideoHelperSuite's VideoCombine, which has an audio input for exactly this.total_frame(INT) - the aligned frame count it computed. Wire this into a text/preview node and glance at it once; it's the fastest sanity check that your frame math was right.
Install
It's in ComfyUI Manager - search "Comfyui-PainterAudioCut". Or the manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/princepainter/Comfyui-PainterAudioCut
Restart ComfyUI. There's no requirements.txt and no model download; it only imports torch and numpy, both already present. The node appears under audio/processing.
Where people get burned
- The rounding always goes up. If your slice lands at 120 frames, the node pads to 121 - fine. But if you miscounted and it lands at 122, you get 125, and now your audio is a few frames longer than the video. Set your start/end/head/tail so the total is at or just below your target 4N+1, then let the padding absorb the rest.
start_framemust be less thanend_frame. The code raises aValueErrorif you flip them, and a 0 or negativeframe_ratealso throws. The error message is clear enough; the fix is usually "you typed the frames like timestamps."- It always re-runs. The node's
IS_CHANGEDreturns NaN, which tells ComfyUI to skip caching. Not a bug - but if you're poking around your workflow's caching behavior, know that this node will re-execute on every queue even with unchanged inputs.
Is it a must-have? No. If your Wan audio happens to already land on a valid frame count, you don't need it. But the moment you're syncing real music to a Wan clip by hand, this beats doing the 4N+1 arithmetic in your head on every single render.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| frame_rate | FLOAT | 30.01–120 | — |
| head_silence_frames | INT | 00–1000 | — |
| start_frame | INT | 00–999999 | — |
| end_frame | INT | 301–999999 | — |
| tail_silence_frames | INT | 00–1000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| trimmed_audio | AUDIO | — |
| total_frame | INT | — |