AudioDuration wan
Turn a time or an audio clip into a Wan-safe frame count
- audio
- time(s)
- video_frames
Wan video wants a very specific frame count - not just "seconds times fps." Feed it the wrong number and the tail either gets truncated or comes out warped, which is where the classic "why is my clip two frames short" complaint comes from. This node does that arithmetic for you: give it a time and a target fps, or better, feed it an actual audio clip, and it hands back a frame count that's already rounded to a length Wan will actually accept.
Why the alignment rule exists
Wan's VAE compresses time roughly 4x. N raw frames become ((N-1)//4)+1 latents, and those latents decode back out to (T_lat-1)*4+1 frames - a 4n+1 shape, not an arbitrary number. Ask for 111 frames and you get 111 back only because 111 already happens to land on that pattern; ask for something that doesn't fit and it gets silently rounded, which is exactly the bug people report as "my video came back short." This node's alignment_frames dropdown exists so you don't have to do that division by hand every time.
How it works
Two ways to drive it. Leave audio unconnected and it computes frames from time_custom (seconds) and video_fps directly. Plug an AUDIO input in instead, and the node reads that clip's own length and rate - and per its own description, it ignores time_custom entirely once audio is connected. That second mode is the one you want for lip-sync or audio-driven video: point it at your voice track, and the frame count it hands back matches your audio exactly, pre-aligned for Wan.
The inputs and outputs that matter
time_custom(default 0) - target duration in seconds. Only used when no audio is wired in.video_fps(default 16) - the frame rate you're targeting. 16 fps is the rate a lot of community Wan clips get generated and shared at, so the default is a reasonable one to leave alone unless your pipeline runs something else.alignment_frames(default8n+1(wan2.1)) - the rounding rule:None,4n+1,6n+1,8n+1(wan2.1),10n+1,15n+1,16n+1. Match this to whichever model you're actually running; the default targets Wan 2.1's own pattern.audio(optional, AUDIO) - when connected, overridestime_customand drives both outputs from the clip itself.
Two outputs: time(s) (FLOAT) and video_frames (INT) - wire the second one straight into whatever length input your Wan sampler expects.
Installing it
Through ComfyUI Manager: search ComfyUI-WJNodes, install, restart. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git
cd ComfyUI-WJNodes
pip install -r requirements.txt
This particular node doesn't pull any model weights - it's pure arithmetic, so once the pack loads you're done with it.
Common issues & troubleshooting
Frame count doesn't match what you expected. Check alignment_frames first. If it's set to a pattern that doesn't match your actual model - say you're on a different Wan revision but left the default 8n+1(wan2.1) - the rounding target is wrong for your pipeline even though the math itself is correct.
The node ignores the time you typed in. That's expected the moment an audio input is connected - the node's own logic drops time_custom as soon as audio is present. Disconnect the audio input if you want to drive it by hand.
Pack-wide load failures. ComfyUI-WJNodes is a large, sprawling grab-bag with a lot of optional integrations (Impact Pack, WAS, EasyOCR, torchvision). If your console shows an import error on startup, it's almost always one specific node elsewhere in the pack missing an optional dependency - AudioDuration_wan itself has no requirements beyond what ComfyUI already ships, so it should load regardless.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| time_custom | FLOAT | 0.0000–1000000 | — |
| video_fps | FLOAT | 16.0001–640 | — |
| alignment_frames | COMBO | 8n+1(wan2.1) | 7 options: None, 4n+1, 6n+1, 8n+1(wan2.1), 10n+1, 15n+1, +1 |
| audioopt | AUDIO | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| time(s) | FLOAT | — |
| video_frames | INT | — |