From 9a901adcc5b976c0cbb872bce21d46240abe3aa5 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Mon, 1 Jun 2026 13:46:29 +0200 Subject: [PATCH] fix(video): double preview on the upload loader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ComfyUI core (frontend 1.42.x) natively renders a node's `ui.gifs` output as a media preview, so our own JS preview widget produced a second one. Return the preview under a custom `universr_videos` key that core ignores; our web extension is now the only thing that renders it — single preview. Co-Authored-By: Claude Opus 4.8 --- nodes_video.py | 10 ++++++---- web/js/UniverSRVideo.js | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/nodes_video.py b/nodes_video.py index 579f819..06eb37a 100644 --- a/nodes_video.py +++ b/nodes_video.py @@ -136,8 +136,10 @@ def _load_video_audio(video_path: str, start_time: float, duration: float) -> di temp_name = _temp_preview_symlink(video_path) ext = (os.path.splitext(video_path)[1] or ".mp4").lstrip(".") - return {"ui": {"gifs": [{"filename": temp_name, "subfolder": "", "type": "temp", - "format": f"video/{ext}"}]}, + # Custom key (not "gifs") so ComfyUI core doesn't ALSO render it — our web + # extension is the only thing that previews it, avoiding a double preview. + return {"ui": {"universr_videos": [{"filename": temp_name, "subfolder": "", "type": "temp", + "format": f"video/{ext}"}]}, "result": (info, audio)} @@ -318,8 +320,8 @@ class UniverSRVideoCombiner: subfolder = os.path.relpath(full_folder, out_dir) if subfolder == ".": subfolder = "" - ui = {"gifs": [{"filename": out_name, "subfolder": subfolder, "type": out_type, - "format": f"video/{src_ext.lstrip('.')}"}]} + ui = {"universr_videos": [{"filename": out_name, "subfolder": subfolder, "type": out_type, + "format": f"video/{src_ext.lstrip('.')}"}]} return {"ui": ui, "result": (str(out_path),)} diff --git a/web/js/UniverSRVideo.js b/web/js/UniverSRVideo.js index fce0c92..6636f5f 100644 --- a/web/js/UniverSRVideo.js +++ b/web/js/UniverSRVideo.js @@ -63,8 +63,9 @@ function addVideoPreview(nodeType) { const onExecuted = node.onExecuted; node.onExecuted = function (output) { onExecuted?.apply(this, arguments); - if (output?.gifs?.[0]) { - const g = output.gifs[0]; + // custom key (see nodes_video.py) — core ignores it, so we render it once + const g = output?.universr_videos?.[0]; + if (g) { const params = new URLSearchParams({ filename: g.filename, type: g.type || "temp",