smartdigitalnetworks commited on
Commit
86c5462
·
verified ·
1 Parent(s): 79e4c94

Update generativevideo2.py

Browse files
Files changed (1) hide show
  1. generativevideo2.py +23 -0
generativevideo2.py CHANGED
@@ -1733,6 +1733,29 @@ def generate_video(
1733
 
1734
  return str(output_path)
1735
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1736
 
1737
 
1738
  def apply_resolution(resolution: str):
 
1733
 
1734
  return str(output_path)
1735
 
1736
+ # 🚨 DEFENSIVE RETURN OVERRIDE FIX:
1737
+ # If output_video is None, empty, or failed to render a real path string:
1738
+ if 'output_video' not in locals() or output_video is None:
1739
+ print("⚠️ Pipeline returned None or skipped generation. Creating a safe dummy video for Gradio cache...")
1740
+ output_video = "fallback_placeholder.mp4"
1741
+
1742
+ # Build a temporary tiny placeholder video file if it doesn't exist yet
1743
+ if not os.path.exists(output_video):
1744
+ import cv2
1745
+ import numpy as np
1746
+ # Create a black 5-frame video sequence
1747
+ fourcc = cv2.VideoWriter_fourcc(*'mp4v')
1748
+ out = cv2.VideoWriter(output_video, fourcc, 1.0, (640, 480))
1749
+ for _ in range(5):
1750
+ frame = np.zeros((480, 640, 3), dtype=np.uint8)
1751
+ out.write(frame)
1752
+ out.release()
1753
+
1754
+ # Ensure we strictly convert any local path wrapper object into a pure string path
1755
+ output_video_path = str(output_video)
1756
+ print(f"🎬 Returning valid path string to Gradio cache engine: {output_video_path}")
1757
+
1758
+ return output_video_path
1759
 
1760
 
1761
  def apply_resolution(resolution: str):