Nodes/WhiteRabbit/πŸ‡ Autocrop to Loop
ComfyUI Node

πŸ‡ Autocrop to Loop

Auto-crops the clip to create a smoother loop: tests crops from the end and scores the seam so it feels like a normal step.

By Artificial-SweetenerΒ·Created 12 months agoΒ·Updated 3 months agoΒ· 75
πŸ‡ Autocrop to Loop
  • clip_frames
  • cropped_clip
  • end_crop_frames
  • cropped_length
  • score
  • diagnostics_csv
β—„max_end_crop_frames12β–Ί
β—„include_first_steptrueβ–Ί
β—„include_last_steptrueβ–Ί
β—„include_global_median_stepfalseβ–Ί
β—„seam_window_frames2β–Ί
β—„distance_metricL1β–Ί
β—„score_in_8bitfalseβ–Ί
β—„use_ssim_similaritytrueβ–Ί
β—„use_exposure_guardtrueβ–Ί
β—„use_flow_guardfalseβ–Ί
β—„weight_step_size0.55β–Ί
β—„weight_similarity0.30β–Ί
β—„weight_exposure0.10β–Ί
β—„weight_flow0.05β–Ί
β—„ssim_downsample_scales1,2β–Ί
β—„accelerate_with_gputrueβ–Ί
β—„use_mixed_precisiontrueβ–Ί
Categoryvideo utils

Inputs (18)

NameTypeDefaultDescription
clip_framesIMAGEYour full clip (NHWC, 0–1). Tries every crop from 0..max_end_crop_frames and returns the best loop.
max_end_crop_framesINT120–10000Largest crop to test at the END. Higher = more candidates (slower), but potentially better.
include_first_stepBOOLEANtrueUse the first neighbor pair (frame 0β†’1) as a target step size/similarity.
include_last_stepBOOLEANtrueUse the last neighbor pair inside the KEPT region as a target.
include_global_median_stepBOOLEANfalseAlso use the median step across the KEPT region (needs β‰₯3 frames). Helps ignore outliers.
seam_window_framesINT21–6Average over multiple aligned pairs across the seam. Larger = more robust.
distance_metricCOMBOL1How to measure step size for matching. L1 is usually more forgiving; MSE penalizes big errors more.
score_in_8bitBOOLEANfalseScore with an 8-bit view (simulate export). Output video still stays float.
use_ssim_similarityBOOLEANtrueInclude SSIM so the seam β€˜looks’ like a normal neighborβ€”avoid freeze or jump.
use_exposure_guardBOOLEANtruePromote smooth brightness across the seam (reduces flicker pops).
use_flow_guardBOOLEANfalseEncourage consistent motion across the seam (needs OpenCV; slower).
weight_step_sizeFLOAT0.550–1Importance of matching step size. Higher = less freeze/jump risk.
weight_similarityFLOAT0.300–1Importance of visual similarity (SSIM). Helps avoid a frozen-looking seam.
weight_exposureFLOAT0.100–1Importance of even brightness across the seam.
weight_flowFLOAT0.050–1Importance of motion continuity across the seam.
ssim_downsample_scalesSTRING1,2SSIM scales to average, as a comma list. Example: 1,2 = full-res and half-res.
accelerate_with_gpuBOOLEANtrueIf ON and CUDA is available, run scoring on GPU for a big speedup (same results).
use_mixed_precisionBOOLEANtrueIf ON (with GPU), use mixed precision for SSIM/conv math (faster on larger clips).

Outputs (5)

NameTypeDescription
cropped_clipIMAGEβ€”
end_crop_framesINTβ€”
cropped_lengthINTβ€”
scoreFLOATβ€”
diagnostics_csvSTRINGβ€”