mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 14:04:50 +00:00
fix(webui): align video timeline duration and formatting with frameio
This commit is contained in:
@@ -27,7 +27,7 @@ import {
|
|||||||
} from '../ui/dropdown-menu'
|
} from '../ui/dropdown-menu'
|
||||||
import { Slider } from '../ui/slider'
|
import { Slider } from '../ui/slider'
|
||||||
import ProgressBar from './progress-bar'
|
import ProgressBar from './progress-bar'
|
||||||
import { formatTimecode } from './utils'
|
import { formatTimecode, formatTime } from './utils'
|
||||||
import { useFramePlayer } from './use-frame-player'
|
import { useFramePlayer } from './use-frame-player'
|
||||||
import { useUiStore } from '@/ui/stores/ui'
|
import { useUiStore } from '@/ui/stores/ui'
|
||||||
|
|
||||||
@@ -120,7 +120,9 @@ const ControlBar: React.FC<ControlBarProps> = ({
|
|||||||
const displayString =
|
const displayString =
|
||||||
videoTimeDisplayMode === 'frames'
|
videoTimeDisplayMode === 'frames'
|
||||||
? `${currentFrame} / ${displayTotalFrames} fr`
|
? `${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 (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -509,7 +511,15 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
|||||||
// Frame-accurate hook and derived state
|
// Frame-accurate hook and derived state
|
||||||
const metadata = data.media.metadata
|
const metadata = data.media.metadata
|
||||||
const frameRate = metadata.frameRate || 30
|
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 { currentFrame, seekToFrame } = useFramePlayer(videoRef, frameRate, totalFrames)
|
||||||
|
|
||||||
const currentTime = currentFrame / frameRate
|
const currentTime = currentFrame / frameRate
|
||||||
|
|||||||
Reference in New Issue
Block a user