1 Star 0 Fork 15

雪狐/ComfyUI_Lam_1

forked from yanlang0123/ComfyUI_Lam 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Image2Video.py 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
马噥 提交于 2年前 . 插件升级
import folder_paths
import cv2
import os
import torch
import numpy as np
import imageio
class Image2Video:
def __init__(self):
self.output_dir = os.path.join(folder_paths.get_output_directory(), 'video')
if not os.path.exists(self.output_dir):
os .makedirs(self.output_dir)
@classmethod
def INPUT_TYPES(s):
return {"required":
{"images": ("IMAGE", ),
"fps": ("INT", {"default": 20, "min": 1, "max": 100000}),
"img_frame_size": ("INT", {"default": 1, "min": 1, "max": 100000}),
"filename_prefix": ("STRING", {"default": "comfyUI"})},
}
CATEGORY = "lam"
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("视频文件名",)
FUNCTION = "img2video"
OUTPUT_NODE = True
#OUTPUT_IS_LIST = (True,)
def img2video(self, images,fps,img_frame_size,filename_prefix):
imaget_np=images.numpy()
imgt_shape=imaget_np.shape
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0])
file = f"{filename}_{counter:05}_.mp4"
with imageio.get_writer(os.path.join(full_output_folder, file), fps=fps) as video:
for i in range(imgt_shape[0]):
imaget=np.uint8(imaget_np[i]*255)
for n in range(img_frame_size):
video.append_data(imaget)# 写入视频
return {"ui": {"text": "视频保存成功文件地址:"+os.path.join(full_output_folder, file),
'videos':[{'filename':file,'type':'output','subfolder':'video'}]}, "result": (os.path.join(full_output_folder, file),)}
NODE_CLASS_MAPPINGS = {
"Image2Video": Image2Video
}
# A dictionary that contains the friendly/humanly readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = {
"Image2Video": "图片转视频"
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/assassindesign/ComfyUI_Lam_1.git
git@gitee.com:assassindesign/ComfyUI_Lam_1.git
assassindesign
ComfyUI_Lam_1
ComfyUI_Lam_1
cu121

搜索帮助