Nodes/MKRShift_Nodes/Auto Reframe Subject
ComfyUI Node

Auto Reframe Subject

Auto-crop a wide video to vertical and follow the subject with it

By criskb·Created 7 months ago·Updated 5 months ago· 0
Auto Reframe Subject
  • video
  • video
  • output_path
  • track_json
  • summary
target_width1080
target_height1920
smoothing0.85
fallback_fps24.0
output_formatauto
filename_prefixMKR_auto_reframe
subfolder
overwritefalse
filename_label

You generated a beautiful 16:9 clip and the client wants it vertical for social. Naive center-crop works until the subject walks to the edge and gets chopped in half. MKRAutoReframeSubject is the "smart crop" that keeps the subject in frame as it moves - it analyzes each frame, finds where the visual weight is, and moves the crop window to follow it, then exports the result at your target resolution. It's the in-graph version of what every video platform now calls auto-reframe.

It lives in the Video/Edit branch of MKRShift_Nodes, next to the match-cut and speed-ramp nodes. Defaults are 1080×1920 - vertical - because that's the shape every request these days is.

How it works - and how it doesn't

Here's the honest bit: there is no AI here, and no face tracking. The node computes a per-frame luminance center of mass: it thresholds the grayscale frame at the 70th percentile, finds the centroid of the bright region, and uses that as the "subject" position. For talking-head content and most shots where the subject is the brightest thing, that's genuinely good enough - and it runs in milliseconds instead of loading a tracking model.

To keep the crop from jittering frame to frame, the centroid passes through exponential smoothing (smoothing, default 0.85): each frame's target is 85% of the previous smoothed value plus 15% of the new one. Higher = steadier but laggier, lower = snappier but shakier. The crop window is clamped to frame bounds, and the cut region is resized to your target with Lanczos.

The trade-off to know: if your subject isn't the brightest region - dark subject on a bright background, or a busy scene - the "subject" drifts to wherever the light is. Don't run this on drone footage of a forest and expect it to track a hiker.

Inputs that matter

  • video - the source; any video-like input the pack can decode (MKR_VIDEO, file path, frames).
  • target_width / target_height - 1080×1920 default. The output resolution and aspect ratio.
  • smoothing - 0 to 0.99, default 0.85. The jitter/steeliness trade.
  • fallback_fps - used if the source doesn't report a rate.
  • output_format - auto/gif/webp/mp4/mov/webm; mp4/mov/webm need ffmpeg.
  • Standard save block: filename_prefix, subfolder, overwrite, optional filename_label.

Outputs: video (MKR_VIDEO), output_path, track_json (a JSON array with each frame's smoothed centroid and the actual crop box - genuinely useful for auditing what it did), and summary.

Install

ComfyUI Manager (search "MKRShift Nodes"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes

Restart. No models to download - this is why it's fast. ffmpeg needed only for mp4/mov/webm output.

Common issues

The bright-subject assumption is the real limit (see above) - if the crop wanders, either brighten/prep the shot upstream or accept the center-crop behavior. Second, smoothing near 0.99 makes the crop feel drunk - it lags the subject badly; 0.7–0.9 is the sane range. And check track_json before you ship: a single bad frame's crop is right there in the data, and it's the fastest way to debug why a shot looks off without scrubbing the whole video.

CategoryMKRShift Nodes/Media/Video/Edit

Inputs (10)

NameTypeDefaultDescription
video*
target_widthINT108064–8192
target_heightINT192064–8192
smoothingFLOAT0.850–0.99
fallback_fpsFLOAT24.01–240
output_formatCOMBOauto6 options: auto, gif, webp, mp4, mov, webm
filename_prefixSTRINGMKR_auto_reframe
subfolderSTRING
overwriteBOOLEANfalse
filename_labeloptSTRING

Outputs (4)

NameTypeDescription
videoMKR_VIDEO
output_pathSTRING
track_jsonSTRING
summarySTRING