From 83ef71934bccfbf0400a78e9c68c6f202b7988f0 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Wed, 17 Sep 2025 19:55:31 +0200 Subject: [PATCH] Enhance tracking marker navigation in VideoEditor This commit improves the navigation logic in the VideoEditor class for jumping to previous and next tracking markers. It ensures that when at the beginning of the tracking frames, the user jumps to the first marker, and when at the end, they jump to the last marker. Debug statements have been updated to reflect these changes, providing clearer insights during navigation. The specification has also been updated to document the new behavior. --- croppa/main.py | 16 +++++++++++----- croppa/spec.md | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/croppa/main.py b/croppa/main.py index 299bbe1..75857fb 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -1076,9 +1076,14 @@ class VideoEditor: return current = self.current_frame candidates = [f for f in tracking_frames if f < current] - target = candidates[-1] if candidates else tracking_frames[-1] - print(f"DEBUG: Jump prev tracking from {current} -> {target}; tracking_frames={tracking_frames}") - self.seek_to_frame(target) + if candidates: + target = candidates[-1] + print(f"DEBUG: Jump prev tracking from {current} -> {target}; tracking_frames={tracking_frames}") + self.seek_to_frame(target) + else: + target = tracking_frames[0] + print(f"DEBUG: Jump prev tracking to first marker from {current} -> {target}; tracking_frames={tracking_frames}") + self.seek_to_frame(target) def jump_to_next_marker(self): """Jump to the next tracking marker (frame with tracking points).""" @@ -1095,8 +1100,9 @@ class VideoEditor: print(f"DEBUG: Jump next tracking from {current} -> {f}; tracking_frames={tracking_frames}") self.seek_to_frame(f) return - print(f"DEBUG: Jump next tracking wrap from {current} -> {tracking_frames[0]}; tracking_frames={tracking_frames}") - self.seek_to_frame(tracking_frames[0]) + target = tracking_frames[-1] + print(f"DEBUG: Jump next tracking to last marker from {current} -> {target}; tracking_frames={tracking_frames}") + self.seek_to_frame(target) def _get_previous_tracking_point(self): """Get the tracking point from the previous frame that has tracking points.""" diff --git a/croppa/spec.md b/croppa/spec.md index f28663f..3063de4 100644 --- a/croppa/spec.md +++ b/croppa/spec.md @@ -68,8 +68,8 @@ Be careful to save and load settings when navigating this way - **Display** Points are rendered as blue dots per frame, in addition the previous tracking point (red) and next tracking point (magenta) are shown with yellow arrows indicating motion direction #### Motion Tracking Navigation -- **,**: Jump to previous tracking marker (previous frame that has one or more tracking points). Wrap-around supported. -- **.**: Jump to next tracking marker (next frame that has one or more tracking points). Wrap-around supported. +- **,**: Jump to previous tracking marker (previous frame that has one or more tracking points). Goes to first marker if at beginning. +- **.**: Jump to next tracking marker (next frame that has one or more tracking points). Goes to last marker if at end. ### Markers and Looping - **1**: Set cut start marker at current frame