Nodes/RyanOnTheInside/Motion Feature βš‘πŸ…‘πŸ…žπŸ…£πŸ…˜
ComfyUI Node

Motion Feature βš‘πŸ…‘πŸ…žπŸ…£πŸ…˜

Turn how (and which way) things move into a reactive signal

By ryanontheinsideΒ·Created 2 years agoΒ·Updated 5 months agoΒ· 852
Motion Feature βš‘πŸ…‘πŸ…žπŸ…£πŸ…˜
  • images
  • roi_mask
  • feature
  • optical_flow
β—„extraction_methodβ–Ύβ–Ί
β—„frame_rate30.0β–Ί
β—„width512β–Ί
β—„height512β–Ί
β—„flow_methodβ–Ύβ–Ί
β—„flow_threshold0.0β–Ί
β—„magnitude_threshold0.00β–Ί

Where AudioFeatureExtractor turns sound into a reactive curve, Motion Feature does the same job for movement in a video. It watches how pixels shift from frame to frame - optical flow, the classic computer-vision technique for estimating per-pixel motion - and boils that down into a single FEATURE number per frame, ready to drive any Flex target elsewhere in the pack. Point it at handheld footage, a dancer, traffic, water - anything with motion - and you get a curve that tracks how much (or which way) things are moving without you hand-keyframing any of it.

How it works

extraction_method picks what exactly gets measured: mean_motion (overall scene movement - the general-purpose choice), max_motion (just the fastest-moving region, good for catching a sudden gesture), motion_direction, horizontal_motion/vertical_motion (isolate one axis), motion_complexity (how chaotic or varied the motion is, not just how much), motion_speed (frame-rate-adjusted so it's comparable across different fps sources), plus onset/acceleration/energy variants for catching the moment motion starts or spikes rather than its steady level.

Under the hood, flow_method picks the optical-flow algorithm: Farneback (dense, smooth, the safest general-purpose default, but slower), the LucasKanade/PyramidalLK family (sparse point tracking, faster but can miss motion in flat, low-texture regions like a plain wall), and DIS (a modern dense method tuned for speed). flow_threshold and magnitude_threshold filter out weak, noisy motion - compression artifacts, sensor noise - so a static shot doesn't register as constant low-level "motion." An optional roi_mask restricts the whole analysis to a region of the frame, useful if you only care about motion in one part of the shot rather than the entire image.

The inputs and outputs that matter

  • images (required, IMAGE) - the sequence to analyze.
  • extraction_method - which motion statistic to extract.
  • flow_method - Farneback / LucasKanade / PyramidalLK / DIS.
  • flow_threshold / magnitude_threshold - noise filtering for the flow field.
  • roi_mask (optional, MASK) - restrict analysis to a region.
  • frame_rate, width/height - standard feature-tensor sizing, matched to your pipeline.

Two outputs: feature (FEATURE, the reactive signal itself) and optical_flow (OPTICAL_FLOW, the raw flow field, for whatever other node in this pack's OpticalFlow family is built to consume it directly rather than recomputing flow from scratch).

How to install it

ComfyUI Manager: search "RyanOnTheInside", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ryanontheinside/ComfyUI_RyanOnTheInside
cd ComfyUI_RyanOnTheInside
pip install -r requirements.txt

then restart. Optical flow here runs on OpenCV, pinned in requirements.txt - no model download, but if the pack's dependencies didn't install cleanly, motion/flow nodes are among the first to error at load time.

Common issues & troubleshooting

Feature stays flat on footage that clearly has motion. Check flow_threshold/magnitude_threshold first - on subtle or slow motion, the defaults can filter out everything before it ever reaches the feature curve. Lower both before assuming the node is broken.

Curve looks noisy and chaotic on handheld or shaky footage. Optical flow can't tell camera shake from subject motion - if your source isn't stabilized, raise the thresholds to filter the shake out, or stabilize the footage upstream first.

Motion in a flat, texture-poor area isn't detected. That's a flow_method issue - Lucas-Kanade-family methods track sparse points and can miss motion where there's little texture to lock onto (a plain wall, a solid-colored shirt). Switch to Farneback or DIS, both dense methods, if that's the footage you're working with.

CategoryRyanOnTheInside/FlexFeatures/Sources

Inputs (9)

NameTypeDefaultDescription
extraction_methodCOMBOChoose how to analyze motion: - mean_motion: Overall amount of movement in the scene - max_motion: Speed of the fastest moving parts - motion_direction: Main direction of movement - horizontal_motion: Amount of left-right movement - vertical_motion: Amount of up-down movement - motion_complexity: How chaotic or varied the motion is - motion_speed: Speed of movement adjusted for frame rate
frame_rateFLOAT30.01–120Frame rate of the video (1.0 to 120.0 fps)
widthINT51264–4096Width of the output feature (64 to 4096)
heightINT51264–4096Height of the output feature (64 to 4096)
imagesIMAGEInput images to analyze
flow_methodCOMBOMethod for calculating optical flow ('Farneback', 'LucasKanade', 'PyramidalLK')
flow_thresholdFLOAT0.00–10Minimum motion magnitude to consider (0.0 to 10.0)
magnitude_thresholdFLOAT0.000–1Relative threshold for motion magnitude (0.0 to 1.0)
roi_maskoptMASKβ€”

Outputs (2)

NameTypeDescription
featureFEATUREβ€”
optical_flowOPTICAL_FLOWβ€”