Nodes/yanhuo-easy-use/视频对比
ComfyUI Node

视频对比

A before/after slider for two videos, paired by time not frame number

By yanhuoxunxianren·Created 27 days ago·Updated 21 days ago· 2
视频对比
  • compare_view
  • video_a
  • video_b
    ◄采样帧数24►
    ◄对齐方式缩放到第一帧►

    ComfyUI has an official image-compare slider - the draggable split line that shows two images overlaid. It works on images. If you want the same thing for video, you're on your own, because there's no such widget for a VIDEO pair out of the box. 视频对比 (YanhuoVideoCompare) is a node that fakes it honestly: it samples paired frames out of two videos along the time axis, then hands them to the official compare widget.

    Why time-aligned sampling is the interesting bit

    The naive way to compare two videos is frame 1 against frame 1, frame 2 against frame 2. Do that with clips of different lengths or frame rates and the comparison drifts - by the end of a sequence you're looking at different moments, and you'll draw the wrong conclusion about a colour shift or an artifact.

    This node samples evenly across the timeline instead. Both videos get 采样帧数 frames picked at even intervals across the longer of the two durations. When one clip is shorter, that clip freezes on its last frame for the remaining samples. So a 3-second clip compared against a 6-second one stays aligned in time for the first half and holds its last frame for the second - which is at least an honest way to show the mismatch rather than pretending it isn't there.

    Inputs and what they do

    • video_a / video_b - both optional VIDEO. Wire two branches of the same pipeline here: original and upscaled, base model and LoRA, one sampler setting versus another. If one is unconnected, black frames at the other's resolution stand in, so the slider still renders. Both empty → the node logs a note and outputs nothing rather than erroring.
    • 采样帧数 - 1 to 250, default 24. How many paired frames to sample. More frames means finer scrubbing and more files written; 24 is a good baseline for a ten-second clip, and the cap exists to stop the temp directory from exploding.
    • 对齐方式 - how to reconcile different resolutions. 缩放到第一帧 stretches B to A's size (may distort); 中心缩放裁切 scales to cover, then centre-crops (no distortion, loses edges); 填充补黑 fits inside with black bars (no distortion, has bars). Same three choices the pack's image merger gives you, which is a nice consistency.
    • compare_view - the official compare widget itself, an IMAGECOMPARE input. It's a widget, not something you wire.

    There are no output ports. The result is the slider on the node; this is an output node, so it always runs and always writes its frames.

    How it produces the slider

    The node reads frames out of the VIDEO object, samples the index list, aligns B to A's dimensions, and then writes both frame sets to ComfyUI's temp directory via the core PreviewImage machinery, under the prefixes comfy.compare.a and comfy.compare.b. It returns those references as a_images and b_images in its UI payload.

    The pack's frontend then feeds those into the slider. That last step is worth understanding if it ever breaks: ComfyUI's official compare extension is hardcoded to the ImageCompare class name, so it will not pick up a custom node's payload. This pack therefore mirrors the official extension in its own JS, finds the compare widget on the node, and sets its beforeImages/afterImages values. If the widget isn't found, you get a console warning listing the widgets it did find - a genuinely helpful failure message, and the first thing to look at if the node renders blank.

    The frontend caveat, stated plainly

    The compare slider is a Nodes 2.0-era component. The pack's own README is blunt: compare_view is only available in the Nodes 2.0 interface. If you're running the legacy canvas, expect an empty node body. That puts this node right in the middle of an ecosystem sore spot - the community has been loud about comparers breaking across frontend changes, and the rgthree image comparer discussion is the canonical example: a comparison slider is precisely the kind of thing people use on every workflow and precisely the kind of thing a rendering rewrite breaks. So if you see this node empty, don't debug your videos; check which canvas you're on first.

    Install

    One of 16 nodes in yanhuo-easy-use (category yanhuo, Chinese labels, MIT, v1.3.1). ComfyUI Manager → search the pack title → install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yanhuoxunxianren/yanhuo-easy-use
    # restart ComfyUI
    

    No pip install - no declared dependencies, and the pack only uses what ComfyUI ships. Hard-refresh the browser after installing so the frontend extension loads. Nothing to download; this node doesn't touch a model.

    Common issues

    "The node is empty / no slider." Two suspects: the frontend extension didn't load (hard-refresh, check the browser console for the "未找到 imagecompare 组件" warning), or you're on the legacy canvas, where the compare component doesn't exist.

    "Two clips of different lengths and the shorter one freezes." That's the designed behaviour, not a bug - time alignment with a last-frame hold. Trim to matching lengths first if you'd rather compare like for like.

    "My temp folder is filling up." Every run writes 采样帧数 × 2 frames into temp/. At the 250 maximum that's 500 images per queue. Raise the count only when you need the detail; delete the temp directory when you're done. It's scratch space and ComfyUI will clear it, but not necessarily before your disk notices.

    "Nothing happens at all." If both inputs are empty - a video branch that failed earlier, or an IMAGE batch plugged into a VIDEO socket - the node reports it in the console and returns nothing. It can't compare what isn't there.

    Categoryyanhuo

    Inputs (5)

    NameTypeDefaultDescription
    采样帧数INT241–250两路视频各均匀采样多少帧配成对(上限 250,防止临时目录爆炸)
    对齐方式COMBO缩放到第一帧两路分辨率不一致时的对齐方式: ● 缩放到第一帧:B 路拉伸到 A 路尺寸(可能变形) ● 中心缩放裁切:等比放大盖住 A 路尺寸后居中裁边(不变形,裁掉边缘) ● 填充补黑:等比缩放到能放进 A 路尺寸,居中补黑(不变形,有黑边)
    compare_viewIMAGECOMPARE—
    video_aoptVIDEOA 路(分割线前的画面),未连接时以黑帧占位
    video_boptVIDEOB 路(分割线后的画面),未连接时以黑帧占位

    Outputs (0)

    No outputs