Add marker navigation functionality to VideoEditor

This commit introduces keyboard controls for jumping to previous and next markers (cut start or end) in the VideoEditor class. The new functionality enhances user navigation during video editing, allowing for more efficient management of cut points. This addition improves the overall editing experience by providing quick access to key markers in the timeline.
This commit is contained in:
2025-09-17 11:31:42 +02:00
parent dd1bc12667
commit 8a7e2609c5

View File

@@ -1057,6 +1057,39 @@ class VideoEditor:
self.current_frame = max(0, min(frame_number, self.total_frames - 1)) self.current_frame = max(0, min(frame_number, self.total_frames - 1))
self.load_current_frame() self.load_current_frame()
def jump_to_previous_marker(self):
"""Jump to the previous defined marker (cut_start_frame/cut_end_frame)."""
if self.is_image_mode:
return
markers = [m for m in [self.cut_start_frame, self.cut_end_frame] if isinstance(m, int)]
if not markers:
return
markers = sorted(set(max(0, min(m, self.total_frames - 1)) for m in markers))
# Find previous marker relative to current_frame (wrap if needed)
prev = None
for m in markers:
if m < self.current_frame:
prev = m
if prev is None:
prev = markers[-1]
self.seek_to_frame(prev)
def jump_to_next_marker(self):
"""Jump to the next defined marker (cut_start_frame/cut_end_frame)."""
if self.is_image_mode:
return
markers = [m for m in [self.cut_start_frame, self.cut_end_frame] if isinstance(m, int)]
if not markers:
return
markers = sorted(set(max(0, min(m, self.total_frames - 1)) for m in markers))
# Find next marker greater than current_frame (wrap if needed)
for m in markers:
if m > self.current_frame:
self.seek_to_frame(m)
return
# Wrap to first
self.seek_to_frame(markers[0])
def advance_frame(self) -> bool: def advance_frame(self) -> bool:
"""Advance to next frame - handles playback speed and marker looping""" """Advance to next frame - handles playback speed and marker looping"""
if not self.is_playing: if not self.is_playing:
@@ -2816,6 +2849,8 @@ class VideoEditor:
print(" 1: Set cut start point") print(" 1: Set cut start point")
print(" 2: Set cut end point") print(" 2: Set cut end point")
print(" T: Toggle loop between markers") print(" T: Toggle loop between markers")
print(" ,: Jump to previous marker")
print(" .: Jump to next marker")
if len(self.video_files) > 1: if len(self.video_files) > 1:
print(" N: Next video") print(" N: Next video")
print(" n: Previous video") print(" n: Previous video")
@@ -2929,14 +2964,14 @@ class VideoEditor:
if not self.is_image_mode: if not self.is_image_mode:
if not self.auto_repeat_active: if not self.auto_repeat_active:
self.start_auto_repeat_seek(1, False, True) # Ctrl+D: +60 frames self.start_auto_repeat_seek(1, False, True) # Ctrl+D: +60 frames
elif key == ord(","): # Comma - Previous frame (unaffected by multiplier) elif key == ord(","):
# Seeking only for videos # Jump to previous marker (cut start or end)
if not self.is_image_mode: if not self.is_image_mode:
self.seek_video_exact_frame(-1) # -1 frame exactly self.jump_to_previous_marker()
elif key == ord("."): # Period - Next frame (unaffected by multiplier) elif key == ord("."):
# Seeking only for videos # Jump to next marker (cut start or end)
if not self.is_image_mode: if not self.is_image_mode:
self.seek_video_exact_frame(1) # +1 frame exactly self.jump_to_next_marker()
elif key == ord("-") or key == ord("_"): elif key == ord("-") or key == ord("_"):
self.rotate_clockwise() self.rotate_clockwise()
print(f"Rotated to {self.rotation_angle}°") print(f"Rotated to {self.rotation_angle}°")