From aa85f523f278f490868626005518c3c05af68933 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Thu, 12 Feb 2026 23:16:01 +0100 Subject: [PATCH] Add optional video preview to TweenConcatVideos Uses ComfyUI's ui/gifs return dict to show the concatenated video directly on the node, matching the VHS Video Combine pattern. Togglable via a preview boolean input (default True). Co-Authored-By: Claude Opus 4.6 --- nodes.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/nodes.py b/nodes.py index f7ce273..4219976 100644 --- a/nodes.py +++ b/nodes.py @@ -376,6 +376,11 @@ class TweenConcatVideos: "tooltip": "Delete the individual segment files after successful concatenation. " "Useful to avoid leftover files that would pollute the next run.", }), + "preview": ("BOOLEAN", { + "default": True, + "tooltip": "Show the concatenated video as a preview on the node. " + "Disable to skip the preview widget.", + }), } } @@ -400,7 +405,7 @@ class TweenConcatVideos: ) return ffmpeg_path - def concat(self, model, output_directory, filename_prefix, output_filename, delete_segments): + def concat(self, model, output_directory, filename_prefix, output_filename, delete_segments, preview): # Resolve output directory out_dir = output_directory.strip() if not out_dir: @@ -473,7 +478,29 @@ class TweenConcatVideos: if os.path.exists(concat_list_path): os.remove(concat_list_path) - return (output_path,) + result = {"result": (output_path,)} + + if preview: + filename = os.path.basename(output_path) + # Determine subfolder relative to ComfyUI output dir + comfy_output = folder_paths.get_output_directory() + if os.path.abspath(out_dir) == os.path.abspath(comfy_output): + subfolder = "" + else: + try: + subfolder = os.path.relpath(out_dir, comfy_output) + except ValueError: + subfolder = "" + result["ui"] = { + "gifs": [{ + "filename": filename, + "subfolder": subfolder, + "type": "output", + "format": "video/mp4", + }] + } + + return result # ---------------------------------------------------------------------------