Nodes/comfyui-ea-nodes/EA Auto Trim (PingPong)
ComfyUI Node

EA Auto Trim (PingPong)

An auto-trim that finds the boring frames, so your loop actually loops

By ExoticArts·Created about a year ago·Updated 10 months ago· 0
EA Auto Trim (PingPong)
  • images
  • images
  • first_frame
  • last_frame
  • frame_count
  • skip_first
  • skip_last
  • debug_image
  • preview_strip
metric_size64
smooth5
warmup_guard6
search_first_pct0.25
search_last_pct0.75
warmup_rel1.20
min_keep32
trim_starttrue
trim_endtrue
min_skip_first0
min_skip_last0
emit_debugtrue
debug_width256
emit_previewfalse
preview_tiles8
dedupe_apextrue

If you've ever hand-trimmed a generated clip so it loops cleanly, you know the pain: scrub to find where the motion settles, delete a few frames, render, eyeball it again. EA Auto Trim (PingPong) tries to do that eyeballing for you. Feed it an image sequence and it finds the quiet start and end of the motion - the dead frames where nothing's happening - and cuts them, so what's left is the part of the loop that actually plays.

It's the most opinionated node in the pack, and the one with the most knobs. Don't let that scare you; the defaults are sane and you'll mostly touch two or three things.

How it works

Under the hood it's a motion-detection heuristic, not ML. The node downscales every frame to a small square (the metric_size knob, default 64), converts to luminance, and computes the mean absolute difference between consecutive frames. That gives you a "motion curve" - low where frames are nearly identical, high where something's moving. It smooths that curve with a moving average (smooth, default 5) and then hunts for the local minima near the start and end: the points where motion is quietest, which is exactly where you want to cut.

A few details worth knowing because they save you debugging time:

  • warmup_guard ignores the first few diffs so frame 0 can't automatically win the "quietest" contest just because the clip hasn't started moving yet.
  • search_first_pct / search_last_pct (defaults 0.25 / 0.75) limit how far into the curve the start and end search windows reach. If the node keeps cutting too much of the front, shrink the first one.
  • min_keep (default 32) is your safety net - it won't trim below this many frames, expanding the span symmetrically if a cut would overshoot.
  • min_skip_first / min_skip_last are hard lower bounds on trimming, useful when you know a specific number of frames at the head/tail are junk.

The outputs that matter

images is your trimmed sequence; wire that to your saver or next node. first_frame and last_frame are convenience previews (handy for checking a loop's join). frame_count, skip_first and skip_last tell you exactly what it did - wire them to a text display and you'll never wonder why a 72-frame clip came out 51.

Then there are the two debug outputs, which are the reason you can tune it blind. debug_image is a tiny chart of the smoothed motion curve with green (start) and red (end) markers. preview_strip (enable emit_preview and set preview_tiles) is a horizontal strip of evenly-spaced frames from the result, boundaries included, so you can see at a glance whether the cut lands where you think it does. emit_debug defaults to true; the debug chart costs almost nothing and tells you more than any help text.

dedupe_apex only affects how the preview strip samples - it's kept for compatibility with the sibling EA PingPong node.

Install and gotchas

Install once for the whole pack - see the pack article or: ComfyUI Manager → search comfyui-ea-nodes → install, restart, hard-refresh. There's no requirements file; everything it needs ships with ComfyUI.

If a trim lands wrong, that's expected on the first pass - read the debug chart, not the frame numbers. Too aggressive? Raise min_keep or shrink the search windows. It's also built with ping-pong loops in mind: run your generated clip through this to shave the dead tail, then feed the result to EA PingPong, and the turnaround point won't have a freeze baked into it.

CategoryEA / Video

Inputs (17)

NameTypeDefaultDescription
imagesIMAGE
metric_sizeoptINT6416–256
smoothoptINT51–31
warmup_guardoptINT60–120
search_first_pctoptFLOAT0.250–0.5
search_last_pctoptFLOAT0.750.5–1
warmup_reloptFLOAT1.200.8–3
min_keepoptINT322–240
trim_startoptBOOLEANtrue
trim_endoptBOOLEANtrue
min_skip_firstoptINT00–240
min_skip_lastoptINT00–240
emit_debugoptBOOLEANtrue
debug_widthoptINT25664–1024
emit_previewoptBOOLEANfalse
preview_tilesoptINT80–64
dedupe_apexoptBOOLEANtrue

Outputs (8)

NameTypeDescription
imagesIMAGE
first_frameIMAGE
last_frameIMAGE
frame_countINT
skip_firstINT
skip_lastINT
debug_imageIMAGE
preview_stripIMAGE