fix(webui): resolve video player total frames mismatch

Avoid deriving total frames from container duration when the audio tail mismatch is below the dynamic playback stall threshold. This prevents the rendering of phantom trailing frames that the playhead cannot reach during playback.

Also adds comprehensive unit and E2E tests covering both small and large audio tail gaps.
This commit is contained in:
yiling
2026-07-04 16:44:09 +08:00
parent f32f2d43aa
commit 175b5ac171
13 changed files with 489 additions and 18 deletions
@@ -9,6 +9,7 @@ import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useSta
import videojs from 'video.js'
import type Player from 'video.js/dist/types/player'
import { useFramePlayer } from '@/ui/components/viewers/use-frame-player'
import { resolveTotalFrames } from '@/ui/components/viewers/utils'
import { clampFrame as clampFrameUtil } from './compare-utils'
import type { ComparePaneHandle, DisplayTranscode, PaneReportedState } from './types'
@@ -109,12 +110,7 @@ export const CompareVideoPane = forwardRef<ComparePaneHandle, CompareVideoPanePr
const frameRate = metadata?.frameRate || 30
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 totalFrames = resolveTotalFrames({ dbTotalFrames, containerDuration, frameRate })
const resolutions = computeResolutions(file)
const previewResolutions = resolutions.filter((r) => !r.isRaw)