Spaces:
Sleeping
Sleeping
Update analyzer/process_video.py
Browse files- analyzer/process_video.py +18 -1
analyzer/process_video.py
CHANGED
|
@@ -120,5 +120,22 @@ def analyze_video(video_path, video_id, user_id):
|
|
| 120 |
|
| 121 |
print(f"β
Saved result to: {output_file}")
|
| 122 |
print(f"β
Returning filename: {video_id}_popup_analysis.png")
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
|
|
|
| 120 |
|
| 121 |
print(f"β
Saved result to: {output_file}")
|
| 122 |
print(f"β
Returning filename: {video_id}_popup_analysis.png")
|
| 123 |
+
|
| 124 |
+
# Save 2β3 key frames as examples
|
| 125 |
+
frame_filenames = []
|
| 126 |
+
for i, frame in enumerate(frames[:3]): # Adjust how many you want
|
| 127 |
+
frame_filename = f"frame_{i}.jpg"
|
| 128 |
+
frame_path = os.path.join(output_folder, frame_filename)
|
| 129 |
+
cv2.imwrite(frame_path, frame)
|
| 130 |
+
frame_filenames.append(frame_filename)
|
| 131 |
+
|
| 132 |
+
# Log output
|
| 133 |
+
print(f"β
Saved plot to: {output_file}")
|
| 134 |
+
print(f"π€ Returning frames: {frame_filenames}")
|
| 135 |
+
|
| 136 |
+
# Return both plot and frame image names
|
| 137 |
+
return {
|
| 138 |
+
"plot": f"{video_id}_popup_analysis.png",
|
| 139 |
+
"frames": frame_filenames
|
| 140 |
+
}
|
| 141 |
|