Display video name and some sort of timestamp

This commit is contained in:
2025-12-29 09:04:21 +01:00
parent 6e8fd4aa42
commit 1aaf5259e2

View File

@@ -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: