재생바 총길이 안정화 — ffprobe 메타 우선 + 없으면 즉석 ffprobe

증상: 영상 재생 시 재생바가 실시간으로 늘어나며 요동침. 총 재생시간이
고정되지 않음.
원인: durationSec가 직접 모드에서 <video>.duration을 우선 사용했는데, 스트림/
일부 컨테이너(리먹스 fMP4 등)에선 재생 중 요소 duration이 계속 커져 재생바가
current/duration 비율로 요동쳤다. 또 메타(duration_ms)가 아직 추출 안 된 영상은
playback_info가 null을 반환해 요소 duration에 의존.

수정:
- VideoPlayer.durationSec: ffprobe 메타 총길이를 항상 우선, 없을 때만 요소 duration
  폴백. (고정 총길이라 재생바 안정)
- playback_info: 영상인데 duration_ms가 null이면 즉석 ffprobe로 채우고 DB에 캐시
  (SMB 등 메타 미추출 상태에서도 정확한 총길이/코덱 보장, 다음 재생부터 재프로브 없음).

검증(VP9 20s): playback_info durationMs=20000, 재생 중 표시 0:00→ 진행하며 총길이는
0:20 고정, 진행바 0%→4%→8% 단조 증가(요동 없음).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
강 한
2026-07-19 23:17:28 +09:00
co-authored by Claude Fable 5
parent ffa737be98
commit 2072f9f27e
2 changed files with 60 additions and 16 deletions
+5 -4
View File
@@ -61,13 +61,14 @@ export const VideoPlayer: Component<{ fileId: number }> = (props) => {
let streamSeekTimer: ReturnType<typeof setTimeout> | undefined;
const isStream = () => plan()?.mode === "stream";
// 재생 길이: 직접 모드는 요소 duration이 진실(메타 없어도 시크바 동작),
// 스트림 모드는 -ss로 잘린 요소 duration이 부정확하므로 메타데이터 우선.
// 재생 길이: ffprobe 총 길이(메타)를 항상 우선. <video> 요소 duration은 스트림·일부
// 컨테이너(리먹스 fMP4 등)에서 재생 중 실시간으로 늘어나 재생바가 요동치므로,
// 메타가 있으면 그 고정 총길이를 쓰고, 없을 때만 요소 duration으로 폴백한다.
const durationSec = () => {
const meta = (pb()?.durationMs ?? 0) / 1000;
if (meta > 0) return meta;
const ed = elDuration();
if (isStream()) return meta > 0 ? meta : ed;
return ed > 0 ? ed : meta;
return ed > 0 ? ed : 0;
};
const cleanupJob = () => {