Repository navigation
feat(timeline): captions inside the vertical feeds' safe area (shorts slice 3) - #85
Merged
Merged
Conversation
Text styles gain an optional margin ({ x, y } pixels from the anchored
edges; absent stays 40, so existing documents render byte for byte).
On a portrait canvas captions default to the safe area: above the bottom
quarter and 14% in from each side, clear of the Shorts, Reels and TikTok
overlays. The caption line limit now follows the font size, so a line
fits between the side margins (22 characters at 54 px on 1080x1920, 32 on
landscape as before), and a bigger font makes shorter lines everywhere.
caption_speech and `clip timeline captions` take a margin; FCPXML places
titles by it too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e word A character count let W- and M-heavy capitals overflow (WOW WOW WOW at 96 px fit 12 characters but not the 754 px of room). Lines now break by an em-width estimate that errs wide, at least Arial's and DejaVu Sans's advance per character class, with the 32-character cap kept. A single word too wide for the room on a line of its own gets a font size that fits it. Measured on 1080x1920: every case inside x 151–929, above 1440. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stimate The box drawtext draws behind a caption reaches 12 px past its text, so on a portrait canvas the text now keeps 163 px from the sides and 492 px from the bottom and the box itself stays within x 151–929, above y 1440. The width estimate counts m, w, # and & as 1 em (DejaVu draws m at 0.97) and any non-Latin letter as 0.9–1 em; accented Latin counts as its base. The CI-gated check now measures each caption's box, for capitals, a 96 px font, a long word, m-heavy lowercase and Cyrillic capitals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DejaVu Sans draws Щ and Ю at about 1.1 em, so a run of them could pass the caption width check and overflow. Non-Latin capitals now count as 1.1 em and lowercase as 0.95. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…afe-zone # Conflicts: # src/mcp/server.ts # src/timeline/captions.ts # src/timeline/shorts.ts
DejaVu Sans draws + = < > ~ ^ at about 0.84 em, so a caption of them could pass the width check and overflow; they now count as 0.85 em. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 0.5.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice 3 of 4 toward v0.5.2 (long recording → vertical shorts). Targets the integration branch
feat/shorts; merging it releases nothing.feat/shortsis merged in, after #78, #83 and #84.Docs: README before · after (one sentence in the captions FAQ); SKILL.md before · after (the "To caption speech" paragraph).
What
TextStyle.margin(src/timeline/composition.ts){ x, y }: how many pixels anchored text keeps from the side and top/bottom edges.compile.ts,anchorPosition()replaces the fixedANCHOR_EXPRtable. FCPXML places Basic Titles by the same margin.Safe area on portrait canvases (
src/timeline/captions.ts)safeArea(comp): the bottom 25% and 14% at each side on a portrait canvas, and 40/40 otherwise (decision 7).defaultCaptionStylesetsmarginon portrait canvases only, and includes the 12 px box drawtext draws behind the text:So the box itself stays inside x 151–929 and above y 1440. Landscape styles get no margin, so they stay as they were.
make_shortpicks this up throughdefaultCaptionStyle.Caption width follows the font (decision 8, changed while building; see Notes)
groupCaptionsbreaks a line when it passes 32 characters, as before, orcaptionWidthBudget(comp, style): the room between the side margins in em of the font. That is 13.96 em at 54 px on 1080x1920 and 34.1 em on landscape.Width comes from
textWidthEm, a per-character-class estimate that errs wide for Arial and DejaVu Sans:Accented Latin counts as its base letter.
fitCaptionStyle: a single word too wide for the room, even on a line of its own, gets a font size that fits it.A larger
--fontmakes shorter lines on every canvas.Margin option
caption_speechgainsmargin(pixels from the bottom or top edge; the sides keep the safe area). The CLI getsclip timeline captions … --margin PX.timeline_editdescription, SKILL.md, the README FAQ andllms.txtmention the safe area.docs/backlog/caption-safe-zone.mdanddocs/backlog/caption-width-follows-font-size.md.Why
On a 9:16 export, bottom-anchored captions sat 40 px from the edge, under the caption text, buttons and progress bar that Shorts, Reels and TikTok draw. A 32-character line in capitals ran almost edge to edge.
How to test
Checks
pnpm lint: clean (the same 7 pre-existing warnings intests/speed.test.tsandtests/transition.test.ts).pnpm type-check: clean.pnpm test: 953 passed, 33 skipped (on the merged tip).pnpm build: OK.Unit tests:
textWidthEmfor W, M, m, Cyrillic, signs and accents;WOW WOW WOWat 96 px breaks; a long word and 13×Щ get fitted fonts.caption_speech: the margin and its schema bound; portrait captions planned with the margin.CI-gated
tests/integration/timeline-caption-safe-zone.test.tsdraws each caption with real drawtext on a black 1080x1920 frame, with a light box so the box's own edges are measured. It runs where FFmpeg has drawtext, so locally withCI=true; it skips on CI's Linux FFmpeg.WOW WOWat 96 pxUNBELIEVABLE, fitted to 81 pxCI=true): 32 passed, 4 skipped.timeline-reviewtimed out once at vitest's default 5 s, then passed twice; that's the known flake indocs/backlog/review-test-timeout.md.Codex review (gpt-6.1-sol), whole slice with the diff inlined:
mand Cyrillic were wider than the estimate;Щat 1.095 em (non-Latin capitals now 1.1).Notes
marginis{ x, y }, not one number. A single value would put a left- or right-anchored portrait caption 480 px from the side.iiiifromWWWW. The 32-character cap stays, so landscape grouping is unchanged for real text.docs/backlog/caption-width-font-metrics.md).clipdropsstyle.marginfrom documents it rewrites.