fix(main.py): handle actual end of video correctly in sequential read fallback

This commit is contained in:
2025-09-04 21:08:16 +02:00
parent 007e371db6
commit 0a73926427

View File

@@ -332,14 +332,25 @@ class VideoEditor:
self.current_frame = new_frame self.current_frame = new_frame
self.current_display_frame = frame self.current_display_frame = frame
return True return True
else: else:
# If sequential read failed, fall back to seeking # If sequential read failed, we've hit the actual end of video
self.current_frame = new_frame # Update total_frames to the actual count and loop
print(f"Reached actual end of video at frame {self.current_frame} (reported: {self.total_frames})")
self.total_frames = self.current_frame
self.current_frame = 0 # Loop back to start
return self.load_current_frame() return self.load_current_frame()
else: else:
# For speed > 1.0, we need to seek to skip frames # For speed > 1.0, we need to seek to skip frames
self.current_frame = new_frame self.current_frame = new_frame
return self.load_current_frame() success = self.load_current_frame()
if not success:
# Hit actual end of video
print(f"Reached actual end of video at frame {self.current_frame} (reported: {self.total_frames})")
self.total_frames = self.current_frame
self.current_frame = 0 # Loop back to start
return self.load_current_frame()
return success
def apply_crop_zoom_and_rotation(self, frame): def apply_crop_zoom_and_rotation(self, frame):
"""Apply current crop, zoom, rotation, and brightness/contrast settings to frame""" """Apply current crop, zoom, rotation, and brightness/contrast settings to frame"""