Nodes/TrentNodes/Black Bar Crop
ComfyUI Node

Black Bar Crop

Stripping the bars back off

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
Black Bar Crop
  • image
  • image
  • width
  • height
target_ratio16:9 (HD/UHD)
threshold0.060
custom_ratio_width0.00
custom_ratio_height0.00

Somewhere between "the model letterboxed my output" and "I grabbed a screenshot of a 2.39:1 movie," you end up with a frame that's half black bars and a subject in a thin strip. BlackBarCrop is the cleanup pass: it scans inward from each edge, finds where the black bars end, crops them off, and optionally center-crops the result to an exact aspect ratio. It's the mirror image of BlackBarCinemaScope in the same pack, and the two pair neatly - one adds cinema bars, the other removes them.

The detection is a brightness scan: it walks inward from each edge and treats pixels below threshold as black. That threshold is the one real knob, and the tooltip is honest about why: "Raise it if compressed bars leave a thin gray edge." Video compression doesn't make bars pure black - it makes them almost black, and if you've ever gotten a two-pixel gray border that refuses to crop, this is the setting. Default is 0.06; compressed footage often wants 0.08–0.1.

The second thing the scan does that's easy to undervalue: it runs across the whole batch at once, so every frame of a video gets the same crop. That's the difference between a crop utility and a crop utility you can use on footage. A per-frame crop would let the detected bar edge wander by a pixel from frame to frame, and on a moving shot that reads as pulsing. This node settles on one crop and applies it everywhere, so the result is stable.

The ratio option

target_ratio defaults to 16:9 (HD/UHD) but has an Auto (remove bars only) option - the tooltip's phrasing is "Auto only removes detected bars," i.e. it crops to the content without forcing an aspect ratio. The other options are the same theatrical standards as BlackBarCinemaScope: 1.85:1, 2.00:1, 2.20:1, 2.35:1, 2.39:1, 2.76:1, 21:9, plus custom ratio via custom_ratio_width/custom_ratio_height (both > 0 to override). When you pick a ratio, after removing bars it center-crops the remaining content to that exact ratio.

Outputs are image, width, and height - the trimmed batch and its new dimensions, which are useful for sanity-checking that the crop actually happened the way you think.

Where it slots in

The natural loop: downscale or crop your source to the visible-area ratio (or just accept bars), run BlackBarCinemaScope to add consistent bars for a trailer template, then use the bar_mask it outputs... or skip all that and just feed your bar-laden frames straight into this node to reclaim the clean 16:9. It's also the honest fix for the classic mistake of generating at 2.39:1 with bars baked in, then needing the flat version for a platform that doesn't want bars.

It's part of TrentNodes - ComfyUI Manager (search "Trent Nodes"), or clone + pip install -r requirements.txt. No models, no downloads; pure torch scanning and cropping. The failure mode is the opposite of the input: feed it a frame that has no bars and it happily crops near-black content from the edges, so check width/height on your first frame before queueing a whole batch.

CategoryTrent/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
target_ratioCOMBO16:9 (HD/UHD)After removing bars, center-crop to this exact aspect ratio. Auto only removes detected bars.
thresholdFLOAT0.0600–0.5Brightness below this counts as black. Raise it if compressed bars leave a thin gray edge.
custom_ratio_widthoptFLOAT0.000–10Custom aspect width (set both width and height > 0 to override preset)
custom_ratio_heightoptFLOAT0.000–10Custom aspect height

Outputs (3)

NameTypeDescription
imageIMAGE
widthINT
heightINT