youssef
commited on
Commit
·
630bec9
1
Parent(s):
378b5d5
test
Browse files- src/app.py +18 -8
src/app.py
CHANGED
@@ -50,22 +50,32 @@ def on_process(video):
|
|
50 |
]
|
51 |
|
52 |
logger.info(f"Processing video: {video}")
|
53 |
-
|
54 |
-
|
|
|
55 |
total_segments = int(duration / 10) # Using default 10-second segments
|
56 |
|
57 |
-
# Process
|
58 |
-
|
59 |
-
segments
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
progress = int((i + 1) / total_segments * 100)
|
61 |
|
62 |
# Format current segments
|
63 |
formatted_desc = "### Video Analysis by Segments:\n\n"
|
64 |
-
for
|
65 |
-
formatted_desc += f"**[{
|
66 |
|
67 |
yield [
|
68 |
-
f"
|
69 |
formatted_desc,
|
70 |
gr.update(visible=True)
|
71 |
]
|
|
|
50 |
]
|
51 |
|
52 |
logger.info(f"Processing video: {video}")
|
53 |
+
|
54 |
+
# Get duration and calculate total segments
|
55 |
+
duration = get_video_duration_seconds(video)
|
56 |
total_segments = int(duration / 10) # Using default 10-second segments
|
57 |
|
58 |
+
# Process all segments at once
|
59 |
+
yield [
|
60 |
+
f"Processing video... (This may take a while for {total_segments} segments)",
|
61 |
+
"",
|
62 |
+
gr.update(visible=True)
|
63 |
+
]
|
64 |
+
|
65 |
+
# Get all segments in one call
|
66 |
+
all_segments = analyzer.process_video(video)
|
67 |
+
|
68 |
+
# Update progress as we format the results
|
69 |
+
for i, segment in enumerate(all_segments):
|
70 |
progress = int((i + 1) / total_segments * 100)
|
71 |
|
72 |
# Format current segments
|
73 |
formatted_desc = "### Video Analysis by Segments:\n\n"
|
74 |
+
for j in range(i + 1): # Only show processed segments
|
75 |
+
formatted_desc += f"**[{all_segments[j]['timestamp']}]** {all_segments[j]['description']}\n\n"
|
76 |
|
77 |
yield [
|
78 |
+
f"Formatting results... {progress}% complete",
|
79 |
formatted_desc,
|
80 |
gr.update(visible=True)
|
81 |
]
|