From 14f6752de2fa3f22dbbee29e6c36bb62c54704c2 Mon Sep 17 00:00:00 2001 From: yiling Date: Mon, 29 Jun 2026 19:48:28 +0800 Subject: [PATCH] fix(webui): align video timeline duration and formatting with frameio --- .../webui/components/viewers/video-player.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/webui/components/viewers/video-player.tsx b/packages/webui/components/viewers/video-player.tsx index 8376d57f..6c406e3a 100644 --- a/packages/webui/components/viewers/video-player.tsx +++ b/packages/webui/components/viewers/video-player.tsx @@ -27,7 +27,7 @@ import { } from '../ui/dropdown-menu' import { Slider } from '../ui/slider' import ProgressBar from './progress-bar' -import { formatTimecode } from './utils' +import { formatTimecode, formatTime } from './utils' import { useFramePlayer } from './use-frame-player' import { useUiStore } from '@/ui/stores/ui' @@ -120,7 +120,9 @@ const ControlBar: React.FC = ({ const displayString = videoTimeDisplayMode === 'frames' ? `${currentFrame} / ${displayTotalFrames} fr` - : `${formatTimecode(currentFrame, frameRate, videoTimeDisplayMode, startTimecode)} / ${formatTimecode(displayTotalFrames, frameRate, videoTimeDisplayMode, startTimecode)}` + : videoTimeDisplayMode === 'standard' + ? `${formatTimecode(currentFrame, frameRate, 'standard')} / ${formatTime(totalFrames / frameRate)}` + : `${formatTimecode(currentFrame, frameRate, videoTimeDisplayMode, startTimecode)} / ${formatTimecode(displayTotalFrames, frameRate, videoTimeDisplayMode, startTimecode)}` return (
= ({ // Frame-accurate hook and derived state const metadata = data.media.metadata const frameRate = metadata.frameRate || 30 - const totalFrames = metadata.totalFrames || 0 + const dbTotalFrames = metadata.totalFrames || 0 + const containerDuration = metadata.duration || 0 + const videoDuration = dbTotalFrames / frameRate + const frameDuration = 1 / frameRate + + const totalFrames = + containerDuration - videoDuration > 0.5 * frameDuration + ? Math.round(containerDuration * frameRate) + : dbTotalFrames const { currentFrame, seekToFrame } = useFramePlayer(videoRef, frameRate, totalFrames) const currentTime = currentFrame / frameRate