jschwab21 commited on
Commit
b5ce577
·
verified ·
1 Parent(s): 7c1db05

Update video_processing.py

Browse files
Files changed (1) hide show
  1. video_processing.py +8 -5
video_processing.py CHANGED
@@ -164,13 +164,15 @@ def analyze_scene(params):
164
 
165
  return (start_time, end_time, None) # Adjust as needed for error handling
166
 
 
 
167
  def analyze_scenes(video_path, scenes, description):
168
  scene_params = [(video_path, start, end, description) for start, end in scenes]
169
-
170
- # Analyze each scene in parallel
171
- with Pool(processes=4) as pool: # You can set the number of processes based on your system's CPU cores
172
- results = pool.map(analyze_scene, scene_params)
173
-
174
  # Process results to find the best scene
175
  scene_scores = [result for result in results if result[2] is not None] # Filter out scenes with no data
176
  if scene_scores:
@@ -185,6 +187,7 @@ def analyze_scenes(video_path, scenes, description):
185
  return None, {}
186
 
187
 
 
188
  def extract_best_scene(video_path, scene):
189
  if scene is None:
190
  return None
 
164
 
165
  return (start_time, end_time, None) # Adjust as needed for error handling
166
 
167
+ from concurrent.futures import ProcessPoolExecutor
168
+
169
  def analyze_scenes(video_path, scenes, description):
170
  scene_params = [(video_path, start, end, description) for start, end in scenes]
171
+
172
+ # Use ProcessPoolExecutor to handle multiprocessing
173
+ with ProcessPoolExecutor() as executor:
174
+ results = list(executor.map(analyze_scene, scene_params))
175
+
176
  # Process results to find the best scene
177
  scene_scores = [result for result in results if result[2] is not None] # Filter out scenes with no data
178
  if scene_scores:
 
187
  return None, {}
188
 
189
 
190
+
191
  def extract_best_scene(video_path, scene):
192
  if scene is None:
193
  return None