`OffthreadVideo` is pathologically slow / hangs on sources with sparse keyframes

Aperta
#5 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
react, typescript

Direzione di ricerca

Start from the OffthreadVideo component and the ffmpeg call that seeks and decodes each frame; the issue names no file paths, so locate them by searching for OffthreadVideo and the ffmpeg invocation. Reproduce with a sparse-keyframe source such as a 60-fps video encoded with a large GOP. The issue offers three options (probe and warn, re-mux, frame cache) with no decision, so confirm the maintainers' preferred approach before coding. Done means the chosen option either warns or renders the sparse-keyframe source without stalling.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

OffthreadVideo performs a per-frame ffmpeg seek+decode. When the source video has a large GOP (sparse keyframes — common in screen recordings, OBS captures, and re-encodes that didn't override default x264 settings), each seek has to decode from the previous keyframe forward, which is slow and can hang the render entirely on some sources.

Reproduction

  1. Take any 60-fps screen recording (OBS, QuickTime, ffmpeg with defaults). These typically have keyframes every 250 frames (~4s).
  2. Wrap it in <OffthreadVideo src={...} /> and render a composition that plays it.
  3. Render hangs or crawls at ~1 frame/sec when the shot is on-screen. Sometimes hangs indefinitely.

In our project, an 1140-frame <OffthreadVideo> over ubatch_glm.mp4 (20s @ 60fps, ~7 keyframes total) stalled the MyVideo render at the exact frame where that video started playing. Re-encoding the source with -g 30 -keyint_min 30 (keyframe every 0.5s) — going from 7 → 41 keyframes — fully resolved it.

Repro one-liner for the fix

ffmpeg -i input.mp4 -c:v libx264 -crf 20 -preset medium -pix_fmt yuv420p \
       -g 30 -keyint_min 30 -movflags +faststart output.mp4

Expected / suggested behavior

Any one of the following would prevent users from hitting this:

  1. Probe + warn at first use. When OffthreadVideo loads a source, count keyframes vs total frames. If keyframes / total_frames < 1 / fps (i.e. less than 1 keyframe per second of content), log a warning:

    OffthreadVideo: \"video.mp4\" has only N keyframes in M frames (1 every X seconds). Per-frame seek cost will be high. Re-encode with -g <fps> -keyint_min <fps> for fast scrub.

  2. Internal re-mux on first use. Auto-generate a sidecar *.optimized.mp4 with -g 30 and use that for rendering. Cache it next to the source. (Remotion does effectively this by extracting frames to a temp directory.)

  3. Frame cache. Extract all source frames upfront to a temp directory on the first render, then read frames from the cache. Eliminates seek cost entirely after the first pass.

(3) is the cleanest but most invasive. (1) is a one-screen probe at media-load time and prevents the surprise.

Impact

This is the kind of bug where the framework looks broken but the source is at fault — and there's no diagnostic to point users at the source. The render just stalls.

Environment

  • `@rendiv/core`: ^0.1.0
  • `@rendiv/cli`: ^0.1.0
  • ffmpeg: 7.0.2-static
  • OS: Debian inside Docker container (headless)
Lingua principale
TypeScript
Stelle
159
Fork
32
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di thecodacus/rendiv

Tutte le issue di thecodacus/rendiv

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.