test(video): extract calculateFrameCenterTime helper and add unit tests

This commit is contained in:
yiling
2026-06-29 10:10:47 +08:00
parent 9576453a72
commit b173b4910e
3 changed files with 21 additions and 4 deletions
@@ -88,3 +88,9 @@ export const formatFrame = (seconds: number, fps: number): number => {
if (isNaN(seconds) || !fps) return 0
return Math.floor(seconds * fps)
}
export const calculateFrameCenterTime = (frameIndex: number, frameRate: number): number => {
if (!frameRate) return 0
const frameDuration = 1 / frameRate
return frameIndex * frameDuration + frameDuration / 2
}