Nodes/Deforum Nodes/(deforum) Tempo Change Detection
ComfyUI Node

(deforum) Tempo Change Detection

Cut the Scene When the Track Slows Down

By XmYx·Created 3 years ago·Updated 3 months ago· 198
(deforum) Tempo Change Detection
  • audio
  • tempo_change_times
threshold0.5

Music that plays at one tempo forever is boring, and so is animation that reacts to it. (deforum) Tempo Change Detection scans a track, finds the moments where the beat speeds up or slows down, and hands you a frame-accurate timeline of those changes - ready to trigger a cut, a zoom burst, or a full scene change exactly when the music shifts gear.

It's one of the audio nodes in XmYx's Deforum Nodes pack, the ComfyUI port of the animation engine that defined A1111's Deforum extension from late 2022 (documented in the KB's ui-history essay). It works on the pack's AUDIO type, produced by the load-audio side of the ecosystem; the README's recommended-custom-nodes list points you at ComfyUI-AudioScheduler for getting audio in.

How it works

This one leans on librosa, which is why the pack's install pulls it in. The pipeline is a recognizable beat-tracking stack:

  1. Compute the onset strength envelope of the track.
  2. Build a tempogram from it - how strong each tempo is at each moment.
  3. Average the tempogram over time to get a "dynamic tempo" curve.
  4. Mark every point where the absolute change between consecutive values exceeds your threshold. Those are the tempo-change moments.

Then the clever part: the node converts those change times into a boolean sequence at 24 fps - a per-frame series where a 1 marks a change frame and 0 everywhere else. It bakes in the 24fps assumption rather than reading it from anywhere, so if your animation runs at 30fps, the series is still written on a 24fps grid. The output is an AMPLITUDE-type series, which means it slots into the same downstream plumbing as every other audio signal - amplitude-to-schedule and deforum parameter nodes won't know it's actually an event flag.

Inputs and output

  • audio (AUDIO) - required.
  • threshold (FLOAT, default 0.5, range 0–1250) - sensitivity. Higher = only flag big tempo jumps. At the default, it catches moderate changes; on noisy or free-tempo music you'll want to raise it or you'll flag every micro-fluctuation.
  • tempo_change_times (AMPLITUDE) - the 24fps boolean flag series.

One small wart: the node has a debug print that dumps the length of the sequence to your console on every run. Harmless, but don't be startled by the log spam.

Installing it

Part of the Deforum Nodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/XmYx/deforum-comfy-nodes.git

Restart, or install through Manager → "Deforum Nodes" by XmYx. The usual pack caveats hold: heavy install (deforum-studio from git, librosa, moviepy, av, pydub, opencv-contrib, numpy<2.0.0), Python 3.10 per the README. No audio examples ship in the pack, so expect to assemble this chain yourself; the Discord is where working audio workflows circulate.

Common issues

The threshold is the main dial and people often leave it at 0.5 then wonder why a dynamically-shifting electronic track flags constantly - raise it until you're only catching real changes. Also remember the 24fps grid: if you're syncing to a project at another frame rate, you'll need to convert the series yourself. And if the pack won't load at all, the classic orphaned A1111 deforum package is the usual culprit - pip uninstall deforum, then retry in the Manager.

Categorydeforum/audio

Inputs (2)

NameTypeDefaultDescription
audioAUDIO
thresholdoptFLOAT0.50–1250

Outputs (1)

NameTypeDescription
tempo_change_timesAMPLITUDE