diff --git a/py/wan_ai_t2v.py b/py/wan_ai_t2v.py index f90bee2..d063e94 100644 --- a/py/wan_ai_t2v.py +++ b/py/wan_ai_t2v.py @@ -1,20 +1,21 @@ import time import requests -import os -import tempfile import io from .modelverse_api.client import ModelverseClient from comfy.comfy_types.node_typing import IO + # Import VideoFromFile class for ComfyUI video handling try: - # Try the newer import path first from comfy_extras.nodes_video import VideoFromFile except ImportError: try: - # Fallback to older import path from comfy.model_management import VideoFromFile - except: - raise ImportError("VideoFromFile not found") + except ImportError: + # Fallback class when VideoFromFile is not available + class VideoFromFile: + def __init__(self, video_io): + self.video_io = video_io + self.video_data = video_io.getvalue() if hasattr(video_io, 'getvalue') else video_io class Modelverse_WanAIT2V: def __init__(self): @@ -83,34 +84,11 @@ class Modelverse_WanAIT2V: raise Exception(f"Unknown task status: {task_status}") # 3. Download video - response = requests.get(video_url) + response = requests.get(video_url, timeout=120) response.raise_for_status() - - # Extract video data - video_data = response.content - - if not video_data: - raise Exception("No video data was returned") - - print("Video generation completed successfully") - print(f"Downloaded video data size: {len(video_data)} bytes") - - # Convert video data to BytesIO object - video_io = io.BytesIO(video_data) - - # Ensure the BytesIO object is at the beginning + video_io = io.BytesIO(response.content) video_io.seek(0) - - # Return VideoFromFile object - try: - video_obj = VideoFromFile(video_io) - print("VideoFromFile object created successfully") - return (video_obj,) - except Exception as e: - print(f"Error creating VideoFromFile object: {e}") - # If VideoFromFile fails, try returning the raw video data - # This is a fallback that might work with some ComfyUI versions - return (video_data,) + return (VideoFromFile(video_io),) NODE_CLASS_MAPPINGS = {