jschwab21 commited on
Commit
d1268c3
·
verified ·
1 Parent(s): 74ff31b

Update video_processing.py

Browse files
Files changed (1) hide show
  1. video_processing.py +22 -5
video_processing.py CHANGED
@@ -44,19 +44,36 @@ def ensure_video_format(video_path):
44
  return None
45
 
46
  def find_scenes(video_path):
47
- formatted_video_path = ensure_video_format(video_path)
48
- if formatted_video_path is None:
49
- print("Video formatting failed. Exiting scene detection.")
 
 
 
 
 
50
  return []
51
- video_manager = open_video(formatted_video_path)
52
  scene_manager = SceneManager()
53
  scene_manager.add_detector(ContentDetector(threshold=30.0))
54
- scene_manager.detect_scenes(video_manager)
 
 
 
 
 
 
55
  scene_list = scene_manager.get_scene_list()
 
 
 
 
56
  scenes = [(scene[0].get_seconds(), scene[1].get_seconds()) for scene in scene_list]
 
57
  return scenes
58
 
59
 
 
60
  def convert_timestamp_to_seconds(timestamp):
61
  return float(timestamp)
62
 
 
44
  return None
45
 
46
  def find_scenes(video_path):
47
+ print(f"Processing video for scene detection: {video_path}")
48
+ video_path = ensure_video_format(video_path)
49
+ print(f"Video formatted at path: {video_path}")
50
+
51
+ try:
52
+ video_manager = open_video(video_path)
53
+ except Exception as e:
54
+ print(f"Failed to open video: {e}")
55
  return []
56
+
57
  scene_manager = SceneManager()
58
  scene_manager.add_detector(ContentDetector(threshold=30.0))
59
+
60
+ try:
61
+ scene_manager.detect_scenes(video_manager)
62
+ except Exception as e:
63
+ print(f"Error during scene detection: {e}")
64
+ return []
65
+
66
  scene_list = scene_manager.get_scene_list()
67
+ if not scene_list:
68
+ print("No scenes detected.")
69
+ return []
70
+
71
  scenes = [(scene[0].get_seconds(), scene[1].get_seconds()) for scene in scene_list]
72
+ print(f"Detected scenes: {scenes}")
73
  return scenes
74
 
75
 
76
+
77
  def convert_timestamp_to_seconds(timestamp):
78
  return float(timestamp)
79