Skip to content

feat(text): timed text, caption box and SRT/WebVTT caption import - #1854

Merged
magic-peach merged 2 commits into
mainfrom
feat/text-timing
Nov 5, 2026
Merged

magic-peach merged 2 commits into
mainfrom
feat/text-timing

Conversation

@magic-peach

Copy link
Copy Markdown
Collaborator

Phase 5, item 5: text overlays and captions. Position, size, colour and the bundled font were already in place, so this adds the missing timing plus caption support.

What changes

  • Start and end times per text item. "From" and "Until" fields in seconds of the source video, plus Start at playhead, End at playhead and Whole video. A start after its end is refused inline, so the edit never holds an invalid range.
  • Caption box: an optional translucent box behind the text (box=1:boxcolor=black@0.55).
  • Import captions (.srt / .vtt). Each cue becomes a timed, boxed text item near the bottom of the frame, sized to about 4.5% of the output height. Cue numbers, WebVTT headers, NOTE blocks, cue settings and formatting tags are stripped. Files are capped at 1 MB.
  • Limit: MAX_TEXT_OVERLAYS goes from 50 to 500, so an edit can hold a whole caption file. A longer file adds its first 500 cues and says so.
  • Remove all clears the list. List rows show each item's time range.

Export (FFmpeg)

  • Each drawtext gets enable='between(t,a,b)', or gte/lt for a one-sided range.
  • drawtext runs after trim and setpts, so source times are mapped to (time - trimStart) / speed.
  • Text that falls entirely outside the kept part is left out of the filter graph.
  • Text is now centred on its position (x=X-text_w/2:y=Y-text_h/2), matching the preview, which already centred it. Before this, the export drew it from the top-left corner.

Preview

  • Placement: text is laid out within the output frame (the letterbox or the kept part in Fill) and scaled to output pixels, so position and size match the export. Previously it was laid out against the whole viewer at preview-pixel sizes.
  • Timing: timed text shows only during its time. The selected item stays visible at 40% opacity so it can still be dragged.
  • Re-renders: while the video plays, the preview follows frames with requestAnimationFrame and re-renders only when the set of visible items changes.

Project files and telemetry

  • Project files: start, end and box are validated and round-trip.
  • feature_used additions: text_tool (import_captions, set_timing, caption_box) and timed_text (exported). No caption text is ever sent. Documented in docs/DATADOG.md.

Memory

The cost is low: overlays are part of the same filter pass with no extra decoding. Inactive drawtext filters are skipped per frame through timeline support.

Tests

  • Unit: caption parsing (SRT/VTT, CRLF, BOM, tags, bad files, length cap), enable expressions through trim and speed, items left out when outside the kept part, caption box, preview visibility, project round-trip and rejects. Full suite: 537 passed.
  • E2E, test/e2e/captions.spec.ts: imports an SRT and checks that the preview shows each cue only during its time and that an end before the start is refused. It then exports and compares pixels with a plain export: caption drawn at 0.5 s, nothing between cues at 1.8 s, the second caption at 2.5 s. Passes on both the multi-threaded and single-threaded projects locally.
  • Existing text-overlay e2e: still passes with the centred position.

Docs

New "Text and captions" section in docs/USAGE.md.

Text overlays get optional start and end times (in source seconds), drawn
with drawtext's enable expression mapped through the trim and speed, and
left out when outside the kept part. Import captions turns each cue of an
.srt or .vtt file into a timed caption; an edit holds up to 500 text items.
The preview now places and sizes text within the output frame, centred on
its position as the export draws it, and hides text outside its time.
@netlify

netlify Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for reframe-os ready!

Name Link
🔨 Latest commit bf0bf9f
🔍 Latest deploy log https://app.netlify.com/projects/reframe-os/deploys/6aec9f70a7a2a65f5fef1c3e
😎 Deploy Preview https://deploy-preview-1854--reframe-os.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@magic-peach
magic-peach merged commit f65637d into main Nov 5, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant