jschwab21 commited on
Commit
d594b35
·
verified ·
1 Parent(s): eca1099

Update video_processing.py

Browse files
Files changed (1) hide show
  1. video_processing.py +7 -3
video_processing.py CHANGED
@@ -137,9 +137,13 @@ def analyze_scenes(video_path, scenes, description):
137
 
138
  scene_scores.append((scene_prob, start_time, end_time, scene_duration, sentiment_percentages))
139
 
140
- # Sort scenes by probability and select the best scene
141
- scene_scores.sort(reverse=True, key=lambda x: x[0])
142
- best_scene = max(scene_scores, key=lambda x: x[3]) # Select based on duration among the top scenes
 
 
 
 
143
 
144
  if best_scene:
145
  print(f"Best Scene: Start={best_scene[1]}, End={best_scene[2]}, Probability={best_scene[0]}, Duration={best_scene[3]}, Sentiments: {best_scene[4]}")
 
137
 
138
  scene_scores.append((scene_prob, start_time, end_time, scene_duration, sentiment_percentages))
139
 
140
+ # Sort scenes by confidence, highest first
141
+ scene_scores.sort(reverse=True, key=lambda x: x[0])
142
+
143
+ # Select the longest scene from the top 3 highest confidence scenes
144
+ top_3_scenes = scene_scores[:3] # Get the top 3 scenes
145
+ best_scene = max(top_3_scenes, key=lambda x: x[3]) # Find the longest scene from these top 3
146
+
147
 
148
  if best_scene:
149
  print(f"Best Scene: Start={best_scene[1]}, End={best_scene[2]}, Probability={best_scene[0]}, Duration={best_scene[3]}, Sentiments: {best_scene[4]}")