音频到FPS转换
The audio-to-frames math node lip-sync pipelines keep re-deriving
- 音频
- 音频时长(s)
- FPS
Nobody types "audio to fps" into a search box - and yet every talking-head, lip-sync, and digital-human workflow quietly needs this exact calculation. You've got a 12-second audio clip and a video model that wants a frame count, or an FPS number, that lines up with it. The author's README says it plainly: this is for lip-sync and digital-human pipelines, where the audio length and the video frame rate have to agree or your generated mouth drifts off the voice. This node is that agreement, computed for you.
It's refreshingly small. You feed in an AUDIO input, pick a target 帧率 (frames per second, default 25), and it works out the audio's duration in seconds, then multiplies to get the FPS your video should run at. Two knobs do the alignment work:
- 因数 - rounds the result down to a multiple of this number (default 8). Video models and their latent layouts often want frame counts divisible by 8 or 16, so this is the "make it tile-friendly" knob.
- 加1帧 - a one-frame fudge factor, on by default. Leave it on; it exists because real pipelines tend to come up one frame short. If your audio drifts at the end, flip it and see which way the drift goes.
Outputs are two INTs: 音频时长(s) - the duration in whole seconds - and FPS. Feed the FPS into the nodes that size your video latent or set the sampler's frame count, and you've closed the loop between "how long is this voice" and "how many frames do I generate."
How it actually works
The 音频 input is a dict with waveform and sample_rate - that's the AUDIO type some audio-loading and TTS nodes emit. The node reads the waveform's length and sample rate, computes duration = round(samples / sample_rate), then fps = int(duration * 帧率), floors it to a multiple of 因数, and optionally adds the one. If it doesn't get that shape of audio - say you wire a plain tensor into it - it quietly returns (0, 0). So the first question, if you're staring at zeros, is "did I actually give it an AUDIO-typed input?" You need an audio source node upstream; torchaudio is the dependency the pack flags for reading audio files, though the pack's own requirements file marks it optional.
Install
Standard for this pack: ComfyUI Manager → search "muye" → install "ComfyUI-Muye-nodes", restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/muyexiuluo/ComfyUI-Muye-nodes
cd ComfyUI-Muye-nodes
pip install -r requirements.txt
then restart. Note the README's manual block still shows an older ComfyUI_Muye.git URL - use the -nodes one above.
Common issues
Beyond the wrong-audio-type-returns-zeros problem, the main thing that confuses people is the 加1帧 logic: it adds one to the FPS value, not to the frame count, so with short clips the difference is proportionally bigger than you'd expect. And remember the display name here is 音频到FPS转换 with Chinese labels throughout - 帧率 is frame rate, 因数 is the factor, 加1帧 is the fudge. If the node is missing entirely, check the console for a [Muye] Failed to load module line; the pack skips any module that can't import.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| 音频 | AUDIO | — | |
| 帧率 | INT | 251–240 | — |
| 因数 | INT | 81–10000 | — |
| 加1帧 | BOOLEAN | true | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 音频时长(s) | INT | — |
| FPS | INT | — |