Nodes/IAMCCS-nodes/Audio Extension Math (timeline sync)
ComfyUI Node

Audio Extension Math (timeline sync)

The calculator that keeps audio and video in sync

By IAMCCS·Created 11 months ago·Updated 8 days ago· 113
Audio Extension Math (timeline sync)
  • audio
  • cursor_frames_out
  • segment_start_frames
  • segment_end_frames
  • effective_unique_frames
  • trim_frames
  • segment_start_s
  • segment_end_s
  • remaining_frames_after
  • is_last_segment
  • report
fps25.00
segment_index0
generated_frames249
extension_frames249
use_cursor_inputtrue
first_pass_unique_frames0
cursor_frames_in0

The frame-accounting node behind LTX-2 audio-video extension

Multi-pass LTX-2 extension is a game of bookkeeping. Every pass generates raw frames, but only a fraction are new frames - the rest are overlap borrowed from the pass before. If your audio is sliced by raw frames while your video is stitched by unique frames, the sync drifts a little every segment, and by segment 20 your dialogue is half a second late. This node is the accountant that prevents that. It takes the pass's frame numbers and the timeline cursor, and computes exactly where the current segment sits in the stitched timeline - in frames and in seconds - plus how much audio to trim.

The inputs

  • audio, fps (default 25) - the timeline it's accounting against.
  • segment_index - the zero-based pass number.
  • generated_frames - raw frames the current pass produced.
  • extension_frames - the unique frames actually added to the timeline.
  • use_cursor_input (default on) - if true, trust cursor_frames_in as the canonical stitched-timeline cursor rather than recomputing it from scratch. This is the "stateless or stateful?" switch: with the cursor wired from the previous pass's cursor_frames_out, the math chains correctly across the whole loop.

Optional: first_pass_unique_frames (0 means use generated_frames for pass 0 - handy when pass 0 behaves differently because there's no overlap yet), and cursor_frames_in (the cumulative cursor before this pass).

The outputs - the whole point

  • cursor_frames_out - the cumulative cursor after this pass. Wire this into the next pass's cursor_frames_in. This single feedback loop is what keeps long runs honest.
  • segment_start_frames / segment_end_frames - where the unique region lands in the timeline.
  • effective_unique_frames - the true new-frame count, which is what the audio should actually cover.
  • trim_frames - how many raw frames to cut (the overlap you don't re-lay).
  • segment_start_s / segment_end_s - the same bounds in seconds, for audio slicing.
  • remaining_frames_after and is_last_segment - whether there's more timeline after this pass; is_last_segment lets the graph switch behavior on the final pass (no overlap needed, full-length audio).
  • report - a plaintext summary of the arithmetic.

How to use it

Pair it with IAMCCS_AudioExtender, which consumes its outputs (segment_start_frames, effective_unique_frames, timeline_cursor_frames) to slice audio - the tooltips cross-reference each other, and they're clearly designed as a set. Feed the sampler's pass frame counts in, thread cursor_frames_outcursor_frames_in around the loop, and the audio side stays locked to the video side without you doing the math by hand.

It ships in IAMCCS-nodes (Manager: "IAMCCS", or clone IAMCCS/IAMCCS-nodes into custom_nodes, restart). No dependencies beyond standard AUDIO objects. The classic mistake is leaving use_cursor_input off and letting every pass recompute from zero - that works for a single pass but quietly breaks continuity across a loop. Keep the cursor chain connected and read the report if the sync ever looks off; the answer to "which number is wrong" is usually printed right there.

CategoryIAMCCS/Audio

Inputs (8)

NameTypeDefaultDescription
audioAUDIO
fpsFLOAT25.000.001–240Timeline fps used by the stitched video.
segment_indexINT00–100000Zero-based generation pass index.
generated_framesINT2491–100000Raw frames produced by the current pass.
extension_framesINT2491–100000Unique frames actually added to the stitched timeline.
use_cursor_inputBOOLEANtrueIf true, trust cursor_frames_in as the canonical stitched timeline cursor.
first_pass_unique_framesoptINT00–100000Optional explicit unique-frame count for pass 0. 0 means use generated_frames.
cursor_frames_inoptINT00–10000000Cumulative unique-frame cursor before this pass.

Outputs (10)

NameTypeDescription
cursor_frames_outINT
segment_start_framesINT
segment_end_framesINT
effective_unique_framesINT
trim_framesINT
segment_start_sFLOAT
segment_end_sFLOAT
remaining_frames_afterINT
is_last_segmentINT
reportSTRING