From 0a739264276162305b45512ecd19d8132ea55455 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Thu, 4 Sep 2025 21:08:16 +0200 Subject: [PATCH] fix(main.py): handle actual end of video correctly in sequential read fallback --- croppa/main.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/croppa/main.py b/croppa/main.py index beaede8..615ba86 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -332,14 +332,25 @@ class VideoEditor: self.current_frame = new_frame self.current_display_frame = frame return True + else: - # If sequential read failed, fall back to seeking - self.current_frame = new_frame + # If sequential read failed, we've hit the actual end of video + # 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() else: # For speed > 1.0, we need to seek to skip frames 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): """Apply current crop, zoom, rotation, and brightness/contrast settings to frame"""