Add VACE Merge Back node for splicing VACE output into original video

Adds a new node that reconstructs full-length video by splicing VACE
sampler output back into the original clip at the trim positions. Supports
optical flow, alpha, and hard-cut blending at context/generated seams.
Also adds trim_start/trim_end INT outputs to VACESourcePrep.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 22:43:07 +01:00
parent 6fa235f26c
commit 89fa3405cb
5 changed files with 336 additions and 13 deletions

View File

@@ -76,3 +76,63 @@ app.registerExtension({
updateVisibility(modeWidget.value);
},
});
app.registerExtension({
name: "VACE.MergeBack.SmartDisplay",
nodeCreated(node) {
if (node.comfyClass !== "VACEMergeBack") return;
const methodWidget = node.widgets.find(w => w.name === "blend_method");
if (!methodWidget) return;
function toggleWidget(widget, show) {
if (!widget) return;
if (!widget._origType) widget._origType = widget.type;
widget.type = show ? widget._origType : "hidden";
}
function updateVisibility(method) {
const showBlend = method !== "none";
const showOf = method === "optical_flow";
toggleWidget(node.widgets.find(w => w.name === "blend_frames"), showBlend);
toggleWidget(node.widgets.find(w => w.name === "of_preset"), showOf);
node.setSize(node.computeSize());
app.graph.setDirtyCanvas(true);
}
const descriptor = Object.getOwnPropertyDescriptor(methodWidget, "value") ||
{ configurable: true };
const hasCustomAccessor = !!descriptor.get;
if (!hasCustomAccessor) {
let _value = methodWidget.value;
Object.defineProperty(methodWidget, "value", {
get() { return _value; },
set(v) {
_value = v;
updateVisibility(v);
},
configurable: true,
});
} else {
const origGet = descriptor.get;
const origSet = descriptor.set;
Object.defineProperty(methodWidget, "value", {
get() { return origGet.call(this); },
set(v) {
origSet.call(this, v);
updateVisibility(v);
},
configurable: true,
});
}
const origCallback = methodWidget.callback;
methodWidget.callback = function(value) {
updateVisibility(value);
if (origCallback) origCallback.call(this, value);
};
updateVisibility(methodWidget.value);
},
});