added preview video

This commit is contained in:
Inoland
2026-03-30 13:42:02 +04:00
parent fa87511cd0
commit 41379b33da
2 changed files with 56 additions and 0 deletions
+6
View File
@@ -60,6 +60,10 @@ from .src.comfyui_ino_nodes.node_helpers.path_helper import (
LOCAL_NODE_CLASS as CAST_PATH_CLASS,
LOCAL_NODE_NAME as CAST_PATH_NAME
)
from .src.comfyui_ino_nodes.node_helpers.video_helper import (
LOCAL_NODE_CLASS as VIDEO_HELPER_CLASS,
LOCAL_NODE_NAME as VIDEO_HELPER_NAME
)
#--------------------------------- S3 helper ---------------------------------
from .src.comfyui_ino_nodes.s3_helper import (
@@ -111,6 +115,7 @@ _node_classes.update(STRING_HELPER_CLASS)
_node_classes.update(TIME_HELPER_CLASS)
_node_classes.update(CAST_HELPER_CLASS)
_node_classes.update(CAST_PATH_CLASS)
_node_classes.update(VIDEO_HELPER_CLASS)
_node_classes.update(S3_HELPER_CLASS)
@@ -138,6 +143,7 @@ _node_names.update(STRING_HELPER_NAME)
_node_names.update(TIME_HELPER_NAME)
_node_names.update(CAST_HELPER_NAME)
_node_names.update(CAST_PATH_NAME)
_node_names.update(VIDEO_HELPER_NAME)
_node_names.update(S3_HELPER_NAME)
@@ -0,0 +1,50 @@
import os
import random
import folder_paths
from comfy_api.latest import io, ui, Input, Types
class InoPreviewVideo:
def __init__(self):
self.prefix_append = "_temp_" + ''.join(random.choice("abcdefghijklmnopqrstupvxyz") for _ in range(5))
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"enabled": ("BOOLEAN", {"default": True, "label_off": "OFF", "label_on": "ON"}),
"video": ("VIDEO",),
},
"optional": {
"format": (("mp4", "webm", "auto"), {"default": "mp4"}),
"codec": (("h264", "auto"), {"default": "h264"}),
},
}
RETURN_TYPES = ()
FUNCTION = "function"
CATEGORY = "InoNodes"
OUTPUT_NODE = True
def function(self, enabled, video: Input.Video, format="mp4", codec="h264"):
if not enabled:
return {"ui": ui.PreviewVideo([]).as_dict()}
width, height = video.get_dimensions()
full_output_folder, filename, counter, subfolder, _ = folder_paths.get_save_image_path(
"ComfyUI" + self.prefix_append, folder_paths.get_temp_directory(), width, height
)
file = f"{filename}_{counter:05}_.{Types.VideoContainer.get_extension(format)}"
video.save_to(
os.path.join(full_output_folder, file),
format=Types.VideoContainer(format),
codec=codec,
)
return {"ui": ui.PreviewVideo([ui.SavedResult(file, subfolder, io.FolderType.temp)]).as_dict()}
LOCAL_NODE_CLASS = {"InoPreviewVideo": InoPreviewVideo}
LOCAL_NODE_NAME = {"InoPreviewVideo": "Ino Preview Video"}