From 1aaf5259e242fa61393991afb8473ac4ffbe2fcd Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 29 Dec 2025 09:04:21 +0100 Subject: [PATCH] Display video name and some sort of timestamp --- croppa/main.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/croppa/main.py b/croppa/main.py index f02fa62..cf6e5d2 100644 --- a/croppa/main.py +++ b/croppa/main.py @@ -3106,6 +3106,75 @@ class VideoEditor: 1, ) + # Add timestamp and video name in top-right corner + if not self.is_image_mode and self.fps > 0: + # Calculate timestamp from current frame and FPS + time_seconds = self.current_frame / self.fps + hours = int(time_seconds // 3600) + minutes = int((time_seconds % 3600) // 60) + seconds = int(time_seconds % 60) + milliseconds = int((time_seconds % 1) * 1000) + timestamp_text = f"{hours:02d}:{minutes:02d}:{seconds:02d}.{milliseconds:03d}" + else: + timestamp_text = "00:00:00.000" + + video_name_text = self.video_path.name + + # Calculate text size for right alignment + font = cv2.FONT_HERSHEY_SIMPLEX + font_scale = 0.6 + thickness = 2 + + timestamp_size = cv2.getTextSize(timestamp_text, font, font_scale, thickness)[0] + video_name_size = cv2.getTextSize(video_name_text, font, font_scale, thickness)[0] + + # Position in top-right corner with margin + margin = 10 + timestamp_x = self.window_width - timestamp_size[0] - margin + video_name_x = self.window_width - video_name_size[0] - margin + timestamp_y = 30 + video_name_y = 60 + + # Draw timestamp with shadow + cv2.putText( + canvas, + timestamp_text, + (timestamp_x + 2, timestamp_y + 2), + font, + font_scale, + (0, 0, 0), + thickness + 1, + ) + cv2.putText( + canvas, + timestamp_text, + (timestamp_x, timestamp_y), + font, + font_scale, + (255, 255, 255), + thickness, + ) + + # Draw video name with shadow + cv2.putText( + canvas, + video_name_text, + (video_name_x + 2, video_name_y + 2), + font, + font_scale, + (0, 0, 0), + thickness + 1, + ) + cv2.putText( + canvas, + video_name_text, + (video_name_x, video_name_y), + font, + font_scale, + (255, 255, 255), + thickness, + ) + # Draw tracking overlays (points and interpolated cross), points stored in ROTATED space pts = self.tracking_points.get(self.current_frame, []) if not self.is_image_mode else [] for (rx, ry) in pts: