Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -76,11 +76,13 @@ def process_input(uploaded_file, youtube_link, image_url, sensitivity):
|
|
76 |
return None, None, None, "Invalid video properties detected."
|
77 |
|
78 |
output_path = os.path.join(tempfile.gettempdir(), f"out_{os.urandom(8).hex()}.mp4")
|
79 |
-
|
|
|
80 |
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
|
81 |
|
82 |
if not out.isOpened():
|
83 |
-
|
|
|
84 |
|
85 |
processed_frames = 0
|
86 |
while True:
|
@@ -105,7 +107,7 @@ def process_input(uploaded_file, youtube_link, image_url, sensitivity):
|
|
105 |
return None, None, None, "No frames processed from video."
|
106 |
|
107 |
if not os.path.exists(output_path) or os.path.getsize(output_path) < 1024:
|
108 |
-
return None, None, None, f"Output video created but too small ({os.path.getsize(output_path)} bytes) - processing failed."
|
109 |
|
110 |
return output_path, None, output_path, f"Video processed successfully! ({processed_frames}/{frame_count} frames)"
|
111 |
|
|
|
76 |
return None, None, None, "Invalid video properties detected."
|
77 |
|
78 |
output_path = os.path.join(tempfile.gettempdir(), f"out_{os.urandom(8).hex()}.mp4")
|
79 |
+
# Use 'mp4v' instead of 'avc1' as it might work better with Spaces' OpenCV
|
80 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
81 |
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
|
82 |
|
83 |
if not out.isOpened():
|
84 |
+
# Fallback message if VideoWriter fails
|
85 |
+
return None, None, None, "Video processing failed: No suitable encoder available in this environment. Try a different input format or contact support."
|
86 |
|
87 |
processed_frames = 0
|
88 |
while True:
|
|
|
107 |
return None, None, None, "No frames processed from video."
|
108 |
|
109 |
if not os.path.exists(output_path) or os.path.getsize(output_path) < 1024:
|
110 |
+
return None, None, None, f"Output video created but too small ({os.path.getsize(output_path)} bytes) - processing failed. Codec support might be limited."
|
111 |
|
112 |
return output_path, None, output_path, f"Video processed successfully! ({processed_frames}/{frame_count} frames)"
|
113 |
|