diff --git a/__init__.py b/__init__.py index 7dfe102..a638f99 100644 --- a/__init__.py +++ b/__init__.py @@ -22,6 +22,7 @@ except Exception: import ssl from .nodes import NanoBananaPro, BatchNanoBananaPro, GoogleGemini, LoadFile, ImageStitchPro, SaveCleanImage, BatchCleanMetadata, VideoPreview, GoogleVeo, FluxImageEdit, UniversalLLMChat, KlingVideo, KlingFirstLastFrame, KlingMotionControlTest, AspectRatioPreset, MultiResPreview, BatchImagesO1key, Seedance, SeedanceMultiModal, StreamPreview, DoubaoImage, O1keyGPTImage, KVideo +from .nodes import K3Video # 报错弹框友好文案(不修改原节点代码,仅在外层统一处理) _MSG_TIMEOUT = "API 请求超时,请稍后重试或检查网络。" @@ -81,6 +82,7 @@ NODE_CLASS_MAPPINGS = { "DoubaoImage": DoubaoImage, "O1keyGPTImage": O1keyGPTImage, "KVideo": KVideo, + "K3Video": K3Video, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -107,6 +109,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "DoubaoImage": "豆包生图", "O1keyGPTImage": "o1key GPT Image", "KVideo": "K26 图生视频", + "K3Video": "K3 图生视频 自研", } WEB_DIRECTORY = "./web" diff --git a/nodes/K3_video.py b/nodes/K3_video.py new file mode 100644 index 0000000..d292a03 --- /dev/null +++ b/nodes/K3_video.py @@ -0,0 +1,99 @@ +""" +K3 图生视频 自研节点(方案A:经典 INPUT_TYPES 前端壳子) +复刻 Kling 3.0 Video 的前端参数,多镜头通过下拉选择控制分镜数量。 +后端请求尚未实现。 +""" + +try: + from comfy_api.latest import InputImpl + import folder_paths + _FOLDER_PATHS_OK = True +except Exception: + _FOLDER_PATHS_OK = False + + +# ── 常量 ────────────────────────────────────────────────────────────────────── + +_MULTI_SHOT_OPTIONS = [ + "disabled", + "1 storyboard", + "2 storyboards", + "3 storyboards", + "4 storyboards", + "5 storyboards", + "6 storyboards", +] + +_MODELS = ["kling-v3"] +_MODES = ["std", "pro", "4k"] + + +# ── 节点 ────────────────────────────────────────────────────────────────────── + +class K3Video: + """K3 图生视频 自研(前端壳子,后端待实现)""" + + @classmethod + def INPUT_TYPES(cls): + required = { + # 多镜头模式选择 + "多镜头": (_MULTI_SHOT_OPTIONS, { + "default": "disabled", + "tooltip": "disabled:单段模式;N storyboards:启用 N 段分镜。", + }), + # 单段模式字段(多镜头 disabled 时使用) + "提示词": ("STRING", {"multiline": True, "default": ""}), + "负向提示词": ("STRING", {"multiline": True, "default": ""}), + "时长": ([5, 10, 15], { + "default": 5, + "tooltip": "单段模式时长(秒);多镜头模式下由各分镜时长决定。", + }), + # 通用参数 + "生成音频": (["关闭", "打开"], {"default": "关闭"}), + "模型": (_MODELS, {"default": "kling-v3"}), + "模式": (_MODES, {"default": "std"}), + "seed": ("INT", { + "default": 0, "min": 0, "max": 2147483647, + "tooltip": "seed 仅控制节点是否重新运行,结果本身不可复现。", + }), + } + + # 分镜字段放最后,按 分镜N_提示词 / 分镜N_时长 交替排列 + for i in range(1, 7): + required[f"分镜{i}_提示词"] = ("STRING", { + "multiline": True, "default": "", + "tooltip": f"第 {i} 段分镜提示词,最多 512 字符。", + }) + required[f"分镜{i}_时长"] = ("INT", { + "default": 4, "min": 1, "max": 15, + "display": "slider", + "tooltip": f"第 {i} 段分镜时长(秒)。", + }) + + optional = { + "起始帧": ("IMAGE",), + "尾帧": ("IMAGE",), + } + + return {"required": required, "optional": optional} + + RETURN_TYPES = ("VIDEO",) + RETURN_NAMES = ("视频",) + FUNCTION = "generate" + CATEGORY = "comfyui_o1key/KVideo" + + async def generate(self, 多镜头, 提示词, 负向提示词, 时长, + 生成音频, 模型, 模式, seed, + 起始帧=None, 尾帧=None, **kwargs): + raise NotImplementedError("K3 图生视频 自研:后端尚未实现。") + + +# ── 节点注册 ────────────────────────────────────────────────────────────────── + +NODE_CLASS_MAPPINGS = { + "K3Video": K3Video, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "K3Video": "K3 图生视频 自研", +} diff --git a/nodes/__init__.py b/nodes/__init__.py index 278c68e..9e33ed8 100644 --- a/nodes/__init__.py +++ b/nodes/__init__.py @@ -21,5 +21,6 @@ from .seedance_video import Seedance, SeedanceMultiModal from .doubao_image import DoubaoImage from .gpt_image import O1keyGPTImage from .K_video import KVideo +from .K3_video import K3Video -__all__ = ['NanoBananaPro', 'BatchNanoBananaPro', 'GoogleGemini', 'LoadFile', 'ImageStitchPro', 'SaveCleanImage', 'BatchCleanMetadata', 'VideoPreview', 'KlingVideo', 'KlingFirstLastFrame', 'KlingMotionControlTest', 'AspectRatioPreset', 'GoogleVeo', 'FluxImageEdit', 'UniversalLLMChat', 'MultiResPreview', 'BatchImagesO1key', 'Seedance', 'SeedanceMultiModal', 'StreamPreview', 'DoubaoImage', 'O1keyGPTImage', 'KVideo'] +__all__ = ['NanoBananaPro', 'BatchNanoBananaPro', 'GoogleGemini', 'LoadFile', 'ImageStitchPro', 'SaveCleanImage', 'BatchCleanMetadata', 'VideoPreview', 'KlingVideo', 'KlingFirstLastFrame', 'KlingMotionControlTest', 'AspectRatioPreset', 'GoogleVeo', 'FluxImageEdit', 'UniversalLLMChat', 'MultiResPreview', 'BatchImagesO1key', 'Seedance', 'SeedanceMultiModal', 'StreamPreview', 'DoubaoImage', 'O1keyGPTImage', 'KVideo', 'K3Video']