|
|
|
|
@ -197,20 +197,65 @@ def generate_video(prompt):
@@ -197,20 +197,65 @@ def generate_video(prompt):
|
|
|
|
|
|
|
|
|
|
# Извлекаем видео |
|
|
|
|
history = get_history(prompt_id)[prompt_id] |
|
|
|
|
|
|
|
|
|
# Логируем структуру для диагностики |
|
|
|
|
logger.info(f"📋 History keys: {list(history.keys())}") |
|
|
|
|
if "outputs" in history: |
|
|
|
|
logger.info(f"📋 Output nodes: {list(history['outputs'].keys())}") |
|
|
|
|
for node_id, node_output in history["outputs"].items(): |
|
|
|
|
logger.info(f"📋 Node {node_id} output keys: {list(node_output.keys())}") |
|
|
|
|
else: |
|
|
|
|
logger.error(f"❌ No 'outputs' in history! History: {json.dumps(history, indent=2)}") |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
# Ищем видео (VHS_VideoCombine может использовать 'gifs' или 'videos') |
|
|
|
|
for node_id in history["outputs"]: |
|
|
|
|
node_output = history["outputs"][node_id] |
|
|
|
|
|
|
|
|
|
# Проверяем оба варианта |
|
|
|
|
video_list = None |
|
|
|
|
if "gifs" in node_output: |
|
|
|
|
for video in node_output["gifs"]: |
|
|
|
|
video_path = video["fullpath"] |
|
|
|
|
video_list = node_output["gifs"] |
|
|
|
|
logger.info(f"✅ Найдено {len(video_list)} видео в node {node_id} (gifs)") |
|
|
|
|
elif "videos" in node_output: |
|
|
|
|
video_list = node_output["videos"] |
|
|
|
|
logger.info(f"✅ Найдено {len(video_list)} видео в node {node_id} (videos)") |
|
|
|
|
|
|
|
|
|
if video_list: |
|
|
|
|
for video in video_list: |
|
|
|
|
logger.info(f"📹 Video info: {video}") |
|
|
|
|
|
|
|
|
|
# Проверяем разные варианты пути |
|
|
|
|
video_path = video.get("fullpath") or video.get("filename") |
|
|
|
|
if not video_path: |
|
|
|
|
logger.error(f"❌ No path in video object: {video}") |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
# Если путь относительный, добавляем COMFY_OUTPUT_DIR |
|
|
|
|
if not os.path.isabs(video_path): |
|
|
|
|
video_path = os.path.join(COMFY_OUTPUT_DIR, video_path) |
|
|
|
|
|
|
|
|
|
logger.info(f"📂 Trying to read: {video_path}") |
|
|
|
|
|
|
|
|
|
if not os.path.exists(video_path): |
|
|
|
|
logger.error(f"❌ File not found: {video_path}") |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
with open(video_path, "rb") as f: |
|
|
|
|
video_b64 = base64.b64encode(f.read()).decode("utf-8") |
|
|
|
|
|
|
|
|
|
logger.info(f"✅ Video loaded: {len(video_b64)} chars base64") |
|
|
|
|
|
|
|
|
|
# Очистка |
|
|
|
|
try: |
|
|
|
|
os.remove(video_path) |
|
|
|
|
except OSError: |
|
|
|
|
pass |
|
|
|
|
logger.info(f"🗑️ Deleted: {video_path}") |
|
|
|
|
except OSError as e: |
|
|
|
|
logger.warning(f"⚠️ Failed to delete {video_path}: {e}") |
|
|
|
|
|
|
|
|
|
return video_b64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.error(f"❌ No video found in any output node. Full history: {json.dumps(history, indent=2)}") |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|