ComfyUI Node

VRGDG_AudioDelayByIndex

Stagger audio per chunk with an offset — the sync fix for chunked generation

By vrgamegirl19·Created about a year ago·Updated 2 days ago· 717
VRGDG_AudioDelayByIndex
  • audio
  • audio
chunk_index
delay_ms40.00

Chunked video generation has a classic failure mode: chunk zero looks right, and every chunk after it drifts - the audio and the generated motion slowly walk out of sync the deeper you get. This node exists for exactly that. VRGDG_AudioDelayByIndex applies a fixed delay (in milliseconds) to an audio clip, but only for chunks other than the first. Chunk index 0 is left untouched as the reference; every later chunk gets the same delay_ms pushed onto its front.

The thinking is simple: if each generated chunk arrives slightly late relative to the reference timeline, you add a constant offset to the audio of the later chunks to line them back up. Positive delay_ms pads the start of the waveform with silence (delays it); negative values cut samples from the front (advances it). The default is 40ms - a small nudge that implies the author hit drift around there in practice.

Inputs

  • audio - the AUDIO clip for this chunk.
  • chunk_index - which chunk this is. 0 is always skipped.
  • delay_ms - the offset, from -100ms to +200ms (default 40). Negative advances, positive delays.

Output is a single audio slot. If chunk_index is 0 it passes the audio through untouched and prints a note to the console; otherwise it converts delay_ms to samples at the clip's own sample rate and pads or trims.

The honest caveat

This is a constant-offset tool, which is only the right shape if your drift is roughly constant. If chunks drift more the further they are from the start (common when generation time itself compounds), a fixed 40ms on every chunk won't fix it - you'd want an offset that grows with the index, which this node doesn't do. Use it as a first-order fix: set delay_ms to the measured lag of the worst chunk, and check whether the middle chunks also line up. If they do, you're done. If they don't, your problem is accumulation, not a fixed offset.

Install

Same pack, same ritual: ComfyUI Manager → search "vrgamedev", or git clone https://github.com/vrgamegirl19/comfyui-vrgamedevgirl into ComfyUI/custom_nodes, restart. No models. The pack's requirements (kornia, librosa, imageio) are shared across the pack, and this node itself only needs torch's F.pad plus the AUDIO dict it's handed.

CategoryVRGDG

Inputs (3)

NameTypeDefaultDescription
audioAUDIO
chunk_indexINT
delay_msFLOAT40.00-100–200

Outputs (1)

NameTypeDescription
audioAUDIO