Frame Count (Audio or Manual) (CRT)
Make your video exactly as long as your soundtrack
- audio
- frame_count
Music-video workflows have a boring, fiddly problem: the video has to end when the song ends. You've got a 37.4-second track and a 24 fps sampler, and if you guess the frame count you'll either cut off the last beat or generate dead air. This node does the arithmetic for you - it measures the audio, works out how many frames you need at your chosen fps, and hands you an INT you can plug straight into a frame-count widget.
It's a tiny utility and it earns its keep the moment you've resynced a clip more than once.
How it works
The logic is about as simple as it gets, which is a feature. Feed it an AUDIO tensor and it reads the waveform's sample count, divides by the sample rate to get duration in seconds, then multiplies by your fps to get the frame count. That number comes out the frame_count output.
Two switches change the behavior:
- bypass - skip the audio entirely and just output manual_frame_count. Handy when you have a fixed length in mind or no audio yet.
- quantize_for_wan - rounds the result up to the
4n + 1frame shape that WAN video models expect, with a floor of 5 frames. Leave it off for LTX (which wants 8n + 1 and has its own handling) and flip it on for WAN.
Inputs and outputs
- audio (
AUDIO) - the track you're syncing to. Required even if you plan to bypass, but ignored when bypass is on. - fps - your output framerate, default 24.
- bypass - use the manual value instead.
- manual_frame_count - the fallback, default 120.
- quantize_for_wan - the 4n+1 rounding described above.
Single output: frame_count (INT), which wires into any node that takes a frame count - the LTX 2.3 sampler's frame_count, an empty-latent node, a video-length calculator.
Installing it
Part of CRT-Nodes, so the usual drill: ComfyUI Manager → search CRT-Nodes → install and restart, or clone and pip install:
cd ComfyUI/custom_nodes
git clone https://github.com/PGCRT/CRT-Nodes.git
pip install -r requirements.txt
The audio-handling parts of the pack pull in librosa, soundfile and pedalboard via that requirements file, so a manual install will drag those along.
Where people get burned
If you feed it malformed audio it returns 0 rather than failing loudly - so check the output isn't zero before you wonder why your video is one frame long. And remember the fps here must match the fps you actually encode at; if you compute at 24 but save at 16, your sync drifts even though the math was right. The 4n+1 quantize also only rounds up, so it can overshoot by up to three frames - irrelevant in practice, but it means "exactly the length of the song" is really "at least the length of the song" when that toggle is on.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| fps | INT | 241–240 | — |
| bypass | BOOLEAN | false | — |
| manual_frame_count | INT | 1201–99999 | — |
| quantize_for_wan | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| frame_count | INT | — |