Commit graph

355 commits

Author SHA1 Message Date
juancarlos.cavero
c200cf787c fix(ci): collect every test again — gate-first imports + the deps tests actually need
CI has been red since the July layout work: the workflow installed five
light packages while the suite grew tests importing numpy, and the MCP
endpoint tests added fastapi on top. Two fixes:

- panel_layout/screencast_layout imported main (torch, mediapipe) BEFORE
  their ENABLED gate, so even the disabled path paid the heavy import.
  Move the import below the gate: the default path now imports nothing,
  which is what the gate was for.
- The workflow installs exactly what the collected tests import at
  module level, still excluding the ML stack the lazy imports protect.
  List validated against a clean venv: 382 passed, 3 skipped, 0 import
  errors.
2026-08-04 00:07:29 +02:00
juancarlos.cavero
7eab5649a6 feat(landing): surface the agent API as a hosted-first benefit
The MCP server existed everywhere except the one page most visitors
see. Feature card + FAQ on the landing (mirrored in the SEO fallback,
which must stay in sync with Landing.jsx), and a new row in the README
edition table framing it honestly: both editions serve /mcp, but an
agent needs an endpoint that is always on, and only the hosted one is.
2026-08-04 00:02:16 +02:00
juancarlos.cavero
7d0b243545 chore(mcp): registry caps description at 100 chars 2026-08-03 23:53:34 +02:00
juancarlos.cavero
f10e5ba65a chore(mcp): server.json for the official MCP registry
Describes the remote server (io.github.mutonby/openshorts namespace,
streamable-http at mcp.openshorts.app/mcp, Bearer key header) so
mcp-publisher can publish and republish from the repo root.
2026-08-03 23:36:04 +02:00
juancarlos.cavero
a69f595aa7 feat(seo): /mcp page — the agent surface as citable content
The MCP server documents itself over the protocol, but nothing on the
site existed for a human or an answer engine to cite when asked 'how do
I automate shorts with Claude/ChatGPT'. One page in the established
shape (TL;DR, one question per H2, FAQ schema): connect command, the
six tools, REST + webhooks, self-host parity, and pricing stated next
to every 'free'. Lands in sitemap.xml and llms.txt automatically via
the shared page list.
2026-08-03 23:22:57 +02:00
juancarlos.cavero
8a6ad06c8c fix(subtitles): name the filter option so ffmpeg 8 can parse the burn
ffmpeg 8's filtergraph parser rejects a quoted positional value followed
by more :name=value options — ass='x.ass':fontsdir='…' now fails with
"No option name near …", so every caption burn breaks on ffmpeg >= 8
(found live-testing the MCP add_subtitles tool on a Homebrew 8.1.1).
The named form (ass=filename='…') parses identically on 4.x through 8.
2026-08-03 22:33:16 +02:00
juancarlos.cavero
f10655fd1c feat(agents): the pipeline as a platform — API keys, MCP server, webhooks
Agents don't forget to come back; humans do. Make the whole pipeline
drivable without the dashboard:

- API keys (osk_...): sha256-stored tokens minted from the account page.
  get_current_user_optional resolves them like a session, so metering,
  entitlement, priority and job ownership apply to agents with zero
  endpoint changes. Key management refuses API-key auth (a leaked key
  cannot mint replacements).
- MCP server at /mcp: stateless Streamable-HTTP JSON-RPC, no SDK
  dependency. Six tools (process_video, get_job_status, list_clips,
  get_quota, add_subtitles, publish_clip) that call back into this same
  app in-process via ASGITransport with the caller's auth headers, so
  MCP can never drift from REST behavior. Cloud requires a key;
  self-host stays BYOK-open.
- Completion webhooks: webhook_url (+ optional HMAC webhook_secret) on
  /api/process, SSRF-checked at submit AND delivery, fired once after
  the R2 archive so payloads carry durable links, survives redeploys
  via the resume manifest.
- Dashboard: API keys card in the account page (create once-shown key,
  list, revoke).
- Tests pin BILLING_ENABLED=0 in conftest so the suite no longer
  depends on the developer's personal .env.
2026-08-03 22:33:16 +02:00
juancarlos.cavero
18f2cf4dbd feat(selection): put a floor under the clip count
Prod measurement, 3-ago-2026: 408 of 429 jobs (95%) delivered three clips or
fewer, the mode being ONE. Cross-referenced against retention on the cohort
that signed up 3-7 days ago (old enough to have returned, recent enough that
the 7-day purge has not deleted their user_videos rows):

    clips delivered   users   came back a 2nd day
    1-3                 251   0.4%
    4-9                  31   16.1%

Forty times the retention on the far side of a boundary that 95% of jobs never
crossed. That is the mechanism behind the 96.7% of users who only ever use the
product on a single day.

The shortlist was not the constraint — a 5-minute video already shortlists 5
windows. The detail prompt was: it asked to "prefer one great clip per
candidate window", and both the 2-second rule and STANDS ALONE end in "or skip
it" with no lower bound, as does DIVERSITY's "drop the other". Three rules
pushing down and nothing holding the count up collapses to one clip.

clip_count_targets() now derives a floor and a ceiling from the shortlist size
(3 windows -> 3-6, 5 -> 4-10, 10+ -> 6-12) and the prompt states it. Every
quality rule is untouched — they are validated at 82% against random windows
and this change does not spend that.

A/B on 8 real prod transcripts (3.5-18 min, all of which delivered 1-3 clips in
production), sharing the score pass between variants so only the detail prompt
differs:

    OLD  mean 2.75  median 2.5  <=3 clips: 6/8
    NEW  mean 4.00  median 4.0  <=3 clips: 3/8
    better on 7 of 8, worse on none, one tie (sign test p = 0.016)

The ceiling never bound: the most any video produced was 5 against a ceiling of
8-12, so the model is not padding to hit a number — the floor and the removal
of the one-per-window bias are doing the work. That is the outcome to want.

Read the limits honestly. Three of eight still land at three or fewer, and the
sample under-represents the sub-5-minute videos that are 54% of real jobs and
the hardest case here: both short videos in the set shortlisted only 2 windows
out of the 3-4 that existed, because the SCORE pass returned fewer usable
windows than it was given. That is the next thing to look at, and it caps this
change on exactly the videos that matter most.

CLIP_TARGET_MIN / CLIP_TARGET_MAX override both bounds for further A/B runs
without a deploy.
2026-08-03 11:17:33 +02:00
juancarlos.cavero
db3e7849af feat(billing): measure the click-to-Stripe gap, and sell the outcome
Between 25-jul and 1-ago the upgrade modals logged 35 checkout clicks and
Stripe recorded one new subscription. Nothing in between was measured:
TopUpModal fired only QuotaWallCheckout/UpsellModalCheckout, and
CheckoutStarted lived exclusively in PricingSection, so the funnel could
not tell "never reached Stripe" from "reached Stripe and abandoned".

Both surfaces now emit the same chain — CheckoutStarted (click) ->
CheckoutRedirected (we hold a Stripe URL) -> CheckoutFailed (we don't,
with the reason) — segmented by a `source` prop of wall | upsell |
pricing. The modal also writes the os_pending_checkout stash that
PricingSection already wrote, so a plan bought from a modal stops losing
its revenue attribution on the Subscribed goal.

The modal copy now leads with what the user gets (clips ready to post, a
library that stays) and states the free-plan limit second. Leading with
the watermark and the 7-day deletion framed the paid tier as "pay to undo
restrictions we added", which is the losing side of an argument against
our own MIT repo, whose headline is "no watermarks, no limits".

GPU rendering and the bundled Gemini key stay out of the modal on
purpose: they are the real reasons the cloud beats self-hosting, but the
free plan already gets both, so they belong on the pricing surface facing
repo visitors rather than in a modal shown to someone already using them.
2026-08-02 01:27:35 +02:00
juancarlos.cavero
19e4d73fce feat(layout): shadow mode, decide and log without touching the render
AUTO_LAYOUT=shadow runs the picker, prints one greppable line per job, and
applies nothing. The render is what it would have been with the picker off,
verified end to end on the production image: excel.mp4 decides "screencast",
logs it, and still renders with every layout module disabled.

Everything measured about this picker was measured on 48 YouTube clips chosen
by hand. What users actually upload is a different distribution nobody has
looked at, and the honest way to find out is to ask the question on real jobs
without letting the answer reach the output. A week of this costs 0.002 USD and
~2s per video and cannot damage a clip somebody paid for.

Log line is deliberately not routed through cloud/analytics.py: that path is
opt-in and host-scoped, and a shadow run has to work on any deployment,
self-hosted included.

  [layout-shadow] decision=screencast would_enable=screencast_layout duration=121s
2026-08-01 01:58:19 +02:00
juancarlos.cavero
19531c5b09 feat(selection): require clips to stand alone without sacrificing the payoff
Measured with a blind judge comparing two candidates from the same video,
positions alternated and durations matched. Baseline first: the current
pipeline beats a random window of the same length 82% of the time over 60
comparisons, so selection works and the room is in the remaining 18%.

The judge's stated reasons kept naming something the prompt never asked for:
whether the moment stands on its own. Two versions of that rule were tested.

  v1  "must make sense to someone who has seen nothing else"
      19 vs 20, 49%, p = 1.000  -> nothing
  v2  v1 plus "fix it by moving the START earlier, never by cutting the
      ending short"
      run 1  27 vs 11, 71%, p = 0.014
      run 2  18 vs 13, 58%, p = 0.473   (replication, different seed)
      pooled 45 vs 24, 65%, p = 0.015   -> adopted

Read the replication honestly: it did NOT reproduce 71% on its own. Both runs
point the same way and pooled they clear the bar, but the effect is smaller
than the first run suggested. If the true rate were 71%, seeing 18/31 or worse
has p = 0.085, so this is a weaker effect rather than a contradiction. Adopted
because it is free — no fewer clips, no extra call — and revisit it if another
selection change ever needs the same slot.

The gap between v1 and v2 is the useful finding. Asking for self-containment
alone is inert because the model buys context by delaying the start and pays
for it with the payoff, and the two cancel out; v1's losses were literally "B
ends abruptly in mid-sentence" and "A includes the final call to action".

Median overlap between the two selections was 37-42%, which is what makes the
v1 result meaningful: the prompts really do pick different seconds, so 49%
means "no better", not "no different".

Harnesses kept in the reframe-testing skill (selection_ab.py, prompt_ab.py).
2026-07-31 21:50:07 +02:00
juancarlos.cavero
3818ed9dcd fix(panel): a 2x2 grid for three people, not three bands
Three horizontal bands was the obvious shape and it is geometrically wrong.
A 1080x640 band is LANDSCAPE, so filling one from a 1080-tall source needs a
1551px-wide crop; on a 1920 frame holding three people that reaches both
neighbours, and the rendered bands each showed two faces. Clamping the crop to
the space a person owns then produced 328x194, upscaled 3.3x into a blurry
close-up of a nose. Both were rendered and looked at before this changed.

A 2x2 grid has PORTRAIT tiles (540x960), which ask for a tall narrow crop, the
shape a person actually occupies. Three people take three cells and the fourth
holds the wide shot, letterboxed rather than cropped, which doubles as context
for who else is in the room.

The neighbour clamp stays: it is what stops a crop reaching the next person
whenever the tile aspect would otherwise allow it.

Verified on a synthetic wide shot built from three corpus talking heads (the
first attempt at that was wrong too: hstacking three 640x360 tiles and scaling
to 1080 tall stretched every face 3x and the detector found nothing).
2026-07-31 14:24:46 +02:00
juancarlos.cavero
16fdf3695f feat(reframe): panel layout for 3-4 people, and separation by distance
Generalises stacking past two: three 1080x640 bands, or a 2x2 grid of 540x960.
Same criteria as SPLIT (coexistence in the same frame, minimum size,
separation) because the failure modes are the same.

Every tile the same size on purpose: a bigger tile claims that person matters
more, and the layout has no way to know that.

The separation test moves from horizontal gap to distance between centres.
Measured on a real recording: two webcams on the same side of the frame, 18px
apart horizontally and 545px vertically. Judging by horizontal gap alone called
them the same person and threw the scene away.

Added overlap suppression (IoU) before counting heads. It is a guard rather
than a fix for a measured bug: on the corpus no pair of boxes exceeds the
threshold, so today it changes no decision.

NOT VALIDATED against real material: of eight panel downloads three failed and
none of the other five is a wide shot of 3-4 people.
2026-07-31 13:28:46 +02:00
juancarlos.cavero
38f37137ee fix(audio,punch): true-peak headroom and punch-in calibration
Two defects affecting EVERY clip, both measured on the corpus.

Audio: loudnorm hits the level target (median -14.2 LUFS, 13/14 inside the
band) but its true-peak ceiling is enforced BEFORE the AAC encode, and the
codec then adds inter-sample peaks on top. At TP=-1.5 one clip came out at
+0.2 dBTP, i.e. clipping. TP=-2.0 removes it at no cost to level (12/14 in
band); -3.0 does cost level (8/14). Tried and rejected: an alimiter afterwards
(limits sample peaks, not inter-sample, and measured WORSE at +0.7) and
two-pass loudnorm with linear=true (+0.4, still clipping).

Punch-in: the shipped defaults produced 8.4 punches per minute, one every seven
seconds. Swept both knobs over 20 clips; 18s/0.60 gives a median of 2.8 and a
max of 3.0, chosen for having the tightest spread rather than just the right
median.
2026-07-31 13:28:46 +02:00
juancarlos.cavero
f88d843fda feat(reframe): chain the camera-inset layout behind the screen decision
Tried first as a fourth option for the classifier, and it does not work: on the
5 corpus clips that have a composited webcam, Gemini answered "screencast" on
all 5, in both runs, and overall accuracy fell from 92% to 85% and 83%.

  3 options      44/48  92%   screen preserved 17/20   none intact 27/28
  4 options c1   41/48  85%                    18/20               28/28
  4 options c2   40/48  83%                    18/20               28/28

Read that carefully: the fourth option did no HARM (zero regressions across the
28 that must not be touched, and it actually preserved the screen on one more).
It simply never got the new class right. Whether a webcam rectangle is present
is a geometric question, and the detector answers it 5 of 5 with no false
positives.

So the split is: Gemini decides what the video is, geometry decides the framing.
If the decision is "screencast" and camera_inset finds a rectangle, that layout
is used; otherwise full width.

Verified end to end: figma -> screencast + inset on 4 scenes; excel (presenter
composited full-screen, no rectangle) -> full width, as before.
2026-07-31 13:28:46 +02:00
juancarlos.cavero
9ed025d1c6 feat(reframe): layout for a screen with the camera composited into a corner
One source: the whole screen (a game, a desktop) with the person composited
into a corner. It is how OBS records and how any stream VOD looks, and it is
the case screencast_layout got wrong: there the speaker band is a large crop
taken AROUND the face, which on a full-screen source means more screen. On the
measured Excel clip the output showed the same spreadsheet twice, whole and
enlarged.

What is needed is the inset's own rectangle, and finding it has three traps,
each of which cost an iteration:

- The inset does not touch two edges. YOLO returns an upper-body box that stops
  at the chest, so a webcam pinned to the right side measured 18% clear of the
  bottom and the "corner" filter threw it away. The test that works is subject
  SMALL and OFF-CENTRE.
- A presenter standing in front of a screen passes any geometric filter. What
  separates them is that a composited inset DOES NOT MOVE: 3-11px between
  samples versus 316px for a person. With a plain min-max range the filter was
  too brittle (one lost sample killed three good detections), so it clusters
  around the median and requires a majority.
- The height cannot be scaled from the detection: for a webcam of about 325x180
  YOLO returned 246x86, and growing that shape still cut the head off. It is
  derived from the width assuming 16:9 and pinned to the edge the inset touches.

The filtergraph keeps the screen at full width (the HUD and the edges are the
content) and the camera band takes its height from the inset's real aspect:
forcing a fixed ratio stretched faces 12% horizontally.

Verified on 10 clips: finds the 4 with a composited camera and rejects the 6
without one (presenter in front of a screen, talking heads, presenter
composited full-screen). The miss is a 720p clip whose webcam is too small for
either detector.
2026-07-31 13:28:45 +02:00
juancarlos.cavero
3f7ac4da18 feat(reframe): pick the layout from 12 frames instead of uploading the video
Gemini bills video at ~300 tokens per second. An hour of source is ~1.08M
tokens (past a 1M context window) and a 1-2GB upload to get one word back. This
pipeline ingests hour-long podcasts, so uploading the file failed in exactly the
normal case.

Measured over the same 48 clips against the hand-checked labels:

  whole video          94% / 92% / 96%   18,17,18 of 20 found
  12 frames @ 640px    90% / 90%         15,16 of 20
  12 frames @ 1024px   92%               17 of 20
  24 frames @ 1024px   90%               16 of 20

Resolution was the gap, not frame count: at 640px a spreadsheet is unreadable,
and doubling the frames made it slightly worse. At 1024px the difference from
sending the whole video sits inside the run-to-run variance the whole-video mode
already has (92-96%), at 2.2s per clip instead of ~15s, with a cost that no
longer depends on the source duration.

It also removes the Files API dance: no upload, no waiting for ACTIVE.
2026-07-31 13:28:45 +02:00
juancarlos.cavero
094e13c2f9 feat(reframe): optional layouts, and a Gemini-picked layout per video
Four new layouts, all off by default, plus a picker that decides which one a
video gets.

- SPLIT (split_layout.py): two speakers stacked. The test is COEXISTENCE in the
  same frame, not presence measured separately: BlazeFace loses faces in
  profile, which is how someone sits while listening, so a presence test
  rejects conversations for looking like conversations. Coexistence also
  separates a two-shot from a shot/reverse-shot, where stacking would show the
  same person twice.
- SCREENCAST / WIDE (screencast_layout.py): content over the presenter, or full
  width when the content fills the frame and the presenter is composited on top
  of it (stacking there shows the same thing twice).
- ALTERNATE (active_speaker.py): hard cuts to whoever is talking. Mouth activity
  must be normalised per speaker against their own resting state; raw magnitude
  scales with contrast and lighting and handed one person 90-100% of the scene.
- Punch-in (punch_in.py): a 12% push on the beats, riding the TRACK path by
  widening its per-frame crop command from x-only to w/h/x/y.

layout_picker.py chooses between none/screencast/split with one Gemini call per
source video. Measured over the 48-clip corpus against hand-checked labels:
94/92/96% across three runs, 0-1 false positives out of 28, and 2 clips of 48
changing answer between runs. The key is asking for a DECISION between closed
options rather than a measurement: the four previous attempts (Canny, MSER,
coverage, width) all asked for a number and none separated a spreadsheet from a
corner scoreboard.

app.py exposes all of it per job through `layouts` on /api/process. Without that
field the pipeline behaves exactly as before.

83 new tests, 315 green.
2026-07-31 13:28:45 +02:00
juancarlos.cavero
be4dd06189 fix(captions): keep apostrophes out of the burned subtitle path
Auto-captions have been silently failing in prod on any video whose title
contains an apostrophe — constant in English ("Earth's", "Don't"). The clip
that surfaced it: "Inside Earth's Most Mysterious Temple". Four failures in a
two-hour window, each swallowed by the guard that ships the clip uncaptioned,
so nothing alerted.

The .ass path is interpolated INTO a filter string (-vf ass='...'), where a
literal apostrophe closes the quote and truncates the filter. /api/subtitle has
always been safe because it names its file subs_<i>_<ts>.ass; shipping captions
by default introduced a name built from the clip stem, which carries the title.

So the .ass name drops the stem. It also gains a uuid: clips render in parallel
under CLIP_WORKERS, and a bare timestamp would let two clips in the same second
write the same file and burn each other's captions. The OUTPUT name keeps the
stem, and must — the modal's walk-back and _canonical_clip_file reconstruct the
clean original from it — but that one is only ever an argv element, never
inside a filter.

Smarter escaping was tried first and is worse, so the reasoning is recorded in
_escape_ffmpeg_filter_value rather than left for someone to rediscover: the
shell idiom "'\''" is not understood by ffmpeg's filtergraph parser, which
dropped the apostrophe AND swallowed the following option, resolving
ass='…Earth'\''s.ass':fontsdir='…' to a filename of "…Earths.ass:fontsdir=…".
An apostrophe in a filter path cannot be escaped; it has to be absent.

Verified in the prod image against the failing filename: the burn now produces
a 540x960 clip where it previously errored.
2026-07-29 15:04:50 +02:00
juancarlos.cavero
4c04b37e4f feat(social): send TikTok uploads to drafts instead of publishing
Upload-Post's `post_mode` defaults to DIRECT_POST, so a clip went straight to
the user's TikTok feed. MEDIA_UPLOAD lands it in their drafts to finish in
TikTok's own editor instead.

Drafts are the right default for an automated pipeline: nothing reaches an
audience without the account owner seeing it, and covers, sounds and trending
hashtags are chosen inside TikTok anyway — the parts that decide whether a clip
travels are exactly the parts this cannot do from the outside.

Applied to both paths that can target TikTok (the clip publisher and the
SaaS-shorts publisher) through one constant, so they cannot drift apart.
TIKTOK_POST_MODE=DIRECT_POST restores publishing without a code change.

The UI now says so before the button is pressed, in both publishers, and leads
with the upside rather than the caveat. Without it the change reads as a bug:
someone expecting a live post, finding nothing on their profile, and concluding
the upload failed. The notice also tells them a TikTok notification is coming,
which the Upload-Post docs confirm for MEDIA_UPLOAD ("users will receive an
inbox notification"), so they know where to look.
2026-07-29 00:23:59 +02:00
juancarlos.cavero
51aafb5290 feat(analytics): report job outcomes to OpenPanel, with the user's job index
The browser reports the funnel, but not what decides whether this product
retains: on 26-jul-2026, 491 of the 564 users who ever processed a video did it
exactly once. Every clip-quality fix that shipped that day — 1080p delivery,
captions by default, loudness normalisation — was aimed at that 87%, and
nothing in the stack could measure whether it moved.

Client-side cannot answer it. A render finishes minutes later, often after the
tab is gone, and ad-blockers eat a share of the rest. So the backend now emits
ClipsDelivered / JobFailed with the user's profileId and a `job_index` — the
count of process jobs that user has run. Counting distinct users at index 1
versus index >= 2, before and after today, answers the question directly.
Failures carry the same reason classification the Telegram alerts use, so the
"did it break or did they just not come back" split is visible too.

Fire-and-forget throughout: no config means a silent no-op (the normal state
for self-hosted), every send is a background task, and every failure is
swallowed. Analytics must never slow down or break a job.

Needs OPENPANEL_CLIENT_ID and OPENPANEL_CLIENT_SECRET in the environment — a
WRITE client, which is a different credential from the read/root client the MCP
needs. Verified against the live instance: the write path returns 200 and the
module no-ops cleanly when unconfigured.
2026-07-28 21:49:40 +02:00
victorcavero14
4fcc1cd5ed fix(analytics): make product analytics opt-in and host-scoped
The OpenPanel endpoint and client id were hardcoded in dashboard/index.html, so
every clone, fork and self-hosted deployment inherited them and reported into
the hosted instance's dashboard. src/lib/analytics.js already documents the
intended behaviour ('analytics can never leak into the open-source experience');
this makes that true.

- apiUrl and clientId now come from VITE_OPENPANEL_API_URL /
  VITE_OPENPANEL_CLIENT_ID, substituted by Vite at build time and unset by
  default, so npm run dev and a plain npm run build initialise nothing.
- The third-party script is only fetched once analytics is actually enabled: a
  default build makes no external analytics request at all.
- Reporting is additionally gated on a hostname allowlist, so a dist/ built with
  credentials stays inert if it is served anywhere else.

Verified with a headless browser against real production builds:
  credentials + non-allowlisted host -> no requests
  credentials + allowlisted host     -> initialises and reports
  no credentials + allowlisted host  -> no requests

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-28 09:58:33 +02:00
juancarlos.cavero
8f873296a1 fix(emails): stop duplicate expiry warnings and fix the button that 404s
Two bugs in the "your N clips will be deleted tomorrow" email.

The button pointed at {frontend_url}/dashboard, a route that has never existed:
the app is a single-page app routed entirely through the hash, and #app is what
opens it. Until today /dashboard fell through to the SPA fallback and quietly
showed the marketing landing, so the link looked like it worked. Now that
unknown paths return a real 404 it fails visibly. Both this and the clips-ready
email now link to /#app; the clips-ready one was passing the bare frontend URL,
which showed the landing page to anyone whose browser had not already set the
skip-landing flag.

The duplicate send is worse. De-duplication was `_warned_video_ids`, a set in
process memory, and the warning window is a full day while the sweep runs every
six hours. Any API restart inside that window re-armed the warning for everyone
already told. That is exactly what happened today: the 06:00 warning went out,
three deploys restarted the API (frontend and API share this repo, so the SEO
pushes redeployed both), the container came up at 12:36, and the sweeper's first
run six hours later at 18:36 mailed the same clips again.

Warnings are now recorded in clip_expiry_warnings, keyed by clip id, written
before the send. A new table rather than a column because the schema bootstrap
is create_all, which creates missing tables but never ALTERs one — same reason
SignupAttribution is its own table. The FK cascades from user_videos, so rows
disappear when purge_free_expired deletes the clip and no cleanup pass is needed.

Recording before sending is deliberate: a duplicate email is the failure being
fixed, while a warning row for a mail that then failed to send costs that user
one notice.

No backfill. Clips already warned about have no row yet, so the current cohort
gets one more warning after this deploys and none after that. Backfilling the
window would also silence the first warning for anyone who entered it since the
last sweep, and a missed deletion notice costs the user their clips, while a
duplicate only costs them an email.

Verified against a real Postgres: create_all builds the table, the primary key
rejects a second row for the same clip, the cascade removes warnings when the
clip is deleted, and warn_free_expiring sends exactly one email across two
sweeps plus a module reload standing in for a restart (which is what used to
produce the second email).
2026-07-27 22:31:04 +02:00
juancarlos.cavero
5280054d32 fix(seo): stop the 404 page claiming to be authored content
The 404 was rendered through the same template as the comparison pages, so it
carried a byline and "Published 2024-06-01 / Updated 2026-07-27", and its schema
declared an Article with an author and a publication date. Both assert authorship
of a page nobody wrote, and the date read as a bug to anyone who landed on it.

noindex pages now render without the byline and describe themselves as a plain
WebPage. Verified: 404.html has no byline, no datePublished anywhere, and a
WebPage node; the real pages keep their byline and Article node unchanged.
2026-07-27 12:35:45 +02:00
juancarlos.cavero
985761a340 fix(seo): permanent apex redirect, real 404s, and gallery links that resolve
Three routing fixes, all in nginx.conf so they live in version control.

Apex to www is now a 301. Traefik was answering 307 because Coolify generates
`redirectregex.permanent=false` and hardcodes it, so pinning the label would be
overwritten on the next deploy. Moving the redirect into the container means the
app's `redirect` setting in Coolify must be `both`, otherwise Traefik still
redirects the apex before nginx ever sees it. A temporary redirect consolidates
nothing, and every canonical on the site pointed through it.

Unknown paths now return 404 instead of 200 with the SPA shell. The app routes
entirely through the hash (#/pricing, #/auth/callback), which never reaches the
server, so nothing deep-links to a path and the fallback was load-bearing for
nothing. Answering 200 with byte-identical markup for every made-up path made
the site look like a single page duplicated infinitely. The 404 body is a
branded page generated by the same renderer, marked noindex and kept out of both
the sitemap and llms.txt.

/gallery and /video/* now 301 to api.openshorts.app, which is where those
server-rendered pages actually live. The README has linked them on the apex since
they were written, and the apex quietly served the landing page instead.

Verified against the production nginx config in a container: 15 real routes 200,
6 made-up paths 404, both gallery paths 301 to the API host, apex 301s to www
preserving path and query. Coolify's health check for this app is disabled and
would target /, which still returns 200.
2026-07-27 11:48:33 +02:00
juancarlos.cavero
ce67cdcdf5 feat(seo): make the site readable by AI crawlers
The dashboard is a client-rendered SPA, so the HTML served for / contained an
empty <div id="root"> and nothing else. Googlebot renders JavaScript and saw the
real landing page; GPTBot, ClaudeBot and PerplexityBot do not, and measured the
homepage as zero characters of text. That is why the site ranks #1 in Google for
its own name and is absent from AI answers. Verified: curl with a GPTBot UA
returned 13,651 bytes of markup and 0 characters of body text.

vite-plugin-seo.js fixes it at build time, with no runtime cost and no change to
how the app mounts:

- Injects crawler-visible homepage content into #root. React replaces it on
  mount, so users get the app unchanged. Homepage now serves 7,524 characters
  of text instead of 0.
- Emits eight standalone static pages: four "X alternative" comparisons plus
  free-ai-clip-generator, open-source-video-clipper, how-openshorts-works and an
  /alternatives hub. Commercial-investigation prompts are answered almost
  entirely out of comparison content, and informational pages are cited far more
  than product pages.
- Generates sitemap.xml (was one hand-written URL with a stale lastmod) and
  llms.txt from the same page list so the three cannot drift.

Also corrects three things that were actively misinforming engines:

- canonical pointed at the apex, which 302s to www. It named a URL that only
  ever redirects. Now www everywhere, matching what is served.
- The schema declared one SoftwareApplication at price 0. That is true of the
  self-hosted edition and false of the hosted one, so the whole product read as
  free. Split into SoftwareApplication (MIT, $0) and Service (Cloud, real
  AggregateOffer of $12-59), and the FAQ answers now name both prices together.
- Opus Clip was described as "$15-228/month" and the Cloud tier as a "3-day free
  trial". Both are stale. Competitor pricing now lives in seo/data.js with the
  date it was checked rendered next to it on the page.

nginx: try_files gains $uri.html before $uri/, so the generated pages resolve at
their clean path with a 200. Resolving them as directories makes nginx 301 to a
trailing slash, which would point every canonical at a redirect.

Verified against the production nginx config in a container: all 12 routes 200,
no redirects, all 9 JSON-LD graphs parse, React mounts with a clean console.
2026-07-27 10:56:15 +02:00
juancarlos.cavero
ccaa06a862 docs(readme): stop advertising against our own pricing page
The README opened with "Free & open source... No watermarks, no limits" and
the comparison table listed Price: Free, Watermark: Never, Upload limits:
None. openshorts.app was mentioned only as a gallery link. Anyone arriving
at the site from here expected an unlimited free tool, which is exactly what
the paid plans charge to remove, and the numbers show it: 1.7% of users come
back, identically whether their clips succeeded or failed.

Self-hosting really is free with no watermark and no limits, so that claim
stays. What changes is that the hosted service now exists on this page, with
the two costs it actually covers named up front: the GPU (about 50s per
8-minute video against 5-8 min on CPU) and the managed API keys.

- Lead with a two-column table: self-hosted vs hosted, price, speed, keys,
  limits, setup, data.
- Qualify the three competitor-table rows that read as unconditional.
- Add the hosted option to "How Much Does It Cost?".
2026-07-27 10:39:40 +02:00
juancarlos.cavero
9b01e02a9b feat(attribution): record where each new account came from
Every strategic read on the funnel so far has been inference: 94% of search
clicks are brand queries, so the real acquisition channel is upstream of
Google, but `users` stores no source at all and we cannot tell GitHub from
YouTube from a directory listing, nor say which channel produced the few
accounts that pay.

Capture `document.referrer` + UTM on the first page load, keep it in
localStorage (our own auth redirects destroy the referrer), and post it once
the account exists. First touch wins, so arriving from GitHub and later
returning via a search still attributes to GitHub.

- New `signup_attribution` table rather than columns on `users`: the schema
  bootstrap is create_all, which adds missing tables but never ALTERs an
  existing one, so this lands on deploy with no migration.
- Only recorded for accounts minutes old, so the 1196 existing users cannot
  be mislabelled with their next login.
- ON CONFLICT DO NOTHING for two tabs finishing the same redirect; the client
  call is fire-and-forget and can never fail a sign-in.
2026-07-27 10:39:24 +02:00
juancarlos.cavero
be1093bd4c feat(pricing): sell the GPU, the keys and the setup instead of the software
The pricing page asked people to pay for things our own MIT repo already
gives away for free (no watermark, no limits), and then closed with a
"Self-host free" button competing with the checkout right below the plans.
Nothing named the two costs self-hosting actually has: our GPU and the
managed API keys.

- Name the real hosted value on every plan card, free included, since free
  runs on the same GPU with the same bundled key: ~50s per 8-min video vs
  5-8 min on CPU. Add the missing no-watermark bullet to the paid tiers.
- Turn the landing's "Two ways to use OpenShorts" cards into a real
  side-by-side: GPU vs your CPU, our key vs your keys, we maintain it vs
  you maintain it.
- Add a detailed hosted vs self-hosted table to the standalone #/pricing,
  which had no equivalent. It lives there rather than in PricingSection so
  it does not duplicate the landing block sitting right above it.
- Realign both copies of the billing FAQ and the open-source trust card.

Retention is 1.7% and identical whether clips succeed or fail, so the plans
have to earn their price on running costs, not on features we open source.
2026-07-27 10:21:58 +02:00
juancarlos.cavero
ef7f856469 fix(pricing): name the actual platforms in the auto-posting line
"TikTok, Reels & Shorts" mixes a platform with two format names, so the two
destinations a reader is most likely to be checking for — Instagram and
YouTube — never appear. Spell all three out.
2026-07-26 23:22:23 +02:00
juancarlos.cavero
6c7456cb70 revert(reframe): drop the text-density classifier rule, it measured the wrong thing
The rule was meant to route a screencast that happens to contain one face to
GENERAL, so its headlines don't get cropped mid-word. Testing it against the
case it exists for showed it does the opposite of what it claims.

Measured on a constructed talking-head-beside-a-chart, and the same shot without
the panels:

  with text panels     density 0.012  -> TRACK   (rule missed it)
  same shot, no panels density 0.029  -> TRACK   (scored HIGHER)

Canny counts edges, and a flat panel of text has far fewer of them than ordinary
scene detail like foliage or clothing — so the signal measures visual busyness,
not text. The threshold was wrong too: across 151 frames of real footage the
density ran median 0.007 / p90 0.018 / max 0.068, so 0.085 could never fire.

The underlying problem is real and still open. A fix needs an actual text
detector (MSER or EAST) validated against clips that contain the failure mode —
the current corpus is highlights and vlogs and has almost none, which is why the
broad run only reclassified 2 of 438 scenes and told us nothing.

Keeping a heuristic that has been shown not to work would only add risk, so it
comes out and the finding stays as a comment where the next attempt will read it.
2026-07-26 20:59:04 +02:00
juancarlos.cavero
ea78445953 feat(clips): four quality fixes found by auditing real user output
Captions must always be the LAST layer. Editing or hooking a clip that already
had them burned in produced `edited_subtitled_<...>`, and the next subtitle pass
stacked a second caption layer on top of the first — visibly doubled and
unreadable in a real user clip found in prod today. /api/edit and /api/hook now
derive from the clean file and put captions back afterwards, so a restyle always
has an un-captioned base to burn onto. The latent bug predates auto-captions but
shipping them by default made it the normal path. The walk-back is now one
helper instead of being open-coded in the subtitle endpoint.

Loudness was uncontrolled. A clip inherited whatever its source was mastered at,
measured across real delivered clips from -13.8 LUFS on a loud upload down to
-28 on a quiet talk, while TikTok/Reels/Shorts all normalise playback to around
-14 — so the quiet ones just sound thin in the feed. loudnorm at the clip cut,
where the audio is already being encoded, so it costs nothing. Verified to pull
both extremes to target: -29.7 -> -13.7 and -10.1 -> -13.5. AUDIO_NORMALIZE=0.

The GENERAL layout wasted the frame. Fitting a 16:9 source to full width left
it 608px tall in a 1920 frame: 32% content, 68% blurred filler. Now scaled by
height to 42%, trimming the overflow. Deliberately conservative — GENERAL is
chosen for groups and landscapes, exactly where cropping the sides cuts someone
out, so 0.55 was tried and rejected for throwing away 42% of the width. 0.42
keeps ~76%. GENERAL_CONTENT_HEIGHT_RATIO=0.32 restores the old behaviour.

The TRACK/GENERAL classifier only counted faces, so a screencast that happened
to contain one face was cropped to it — real prod clips came out with headlines
cut mid-word and unreadable. A cheap Canny pass over the side thirds (the part a
9:16 crop discards), with face boxes blanked first, now routes text-dense scenes
to GENERAL instead. GRAPHIC_DENSITY_THRESHOLD=1.0 disables it.
2026-07-26 20:59:04 +02:00
juancarlos.cavero
bdd9e5d53d fix(reframe): ignore lone target jumps so the camera stops swinging
The camera swung between subjects because a single detection could teleport the
target anywhere and the frame followed immediately. On real user footage pulled
from prod, 22% of target updates moved further than the entire safe zone.

A move that large is far more often a detector error — a second face, a false
positive, a box snapping to a different body part — than a person who actually
moved that far. It now has to repeat JUMP_CONFIRM_FRAMES (3) consecutive
detections before the camera commits; a wrong reading disappears on the next
detection and never moves the frame. Contradictory outliers cannot confirm each
other, so a detector flapping between two wrong places holds the frame still.

Measured over 262s of TRACK footage across 12 chunks of two real user videos,
counting only reversals INSIDE a scene (a cut is supposed to re-frame, so
scoring scene-change snaps would measure the feature, not the bug):

  confirm=1   0.41 rev/s   91 px/s      —
  confirm=2   0.20 rev/s   76 px/s   -51%
  confirm=3   0.13 rev/s   60 px/s   -69%
  confirm=4   0.10 rev/s   48 px/s   -76%

3 is the knee: 4 buys another 7 points of reversals for a third more latency.

Honest about the downside — per scene, travel gets calmer in 54 of 84 and is
unchanged in 23, but 7 get BUSIER (worst 59 -> 108px/s, and one dead-still scene
starts drifting at 31px/s), because committing later can leave the camera
further to travel. Net strongly positive, not universally so.

Tried and rejected: a 3s switch cooldown, which bought only -19% on its own and
is precisely what would make a two-person interview stop following the
conversation. JUMP_CONFIRM_FRAMES=1 restores the old behaviour without a deploy.

Methodology note: variants are compared by recording the detections once and
replaying them through the cameraman, so every variant sees identical input
rather than a fresh run of a non-deterministic detector.
2026-07-26 20:59:04 +02:00
juancarlos.cavero
bedecdc850 fix(files): bound filenames by bytes, not characters
/api/hook has been returning 500 in prod on any clip whose video title is
non-Latin: OSError 36, "File name too long". sanitize_filename() capped the
title at 100 CHARACTERS, but filesystems cap a name at 255 BYTES, and one
Bengali or Arabic character costs three — so a title was already ~300 bytes
before the pipeline decorated it.

Every derived name stacks on that stem: "_clip_10.mp4", "subtitled_<ts>_",
"temp_hook_<hex8>_", "autosubs_<ts>_.ass". Shipping captions by default added
one more layer, which is what pushed the borderline cases over and surfaced it.

- sanitize_filename now trims to MAX_TITLE_BYTES (120) via truncate_bytes(),
  which never splits a multi-byte character. 120 leaves room for every
  decoration stacked and still lands well under 255.
- The hook overlay stopped embedding the full source name: its uuid already
  guarantees uniqueness, so the name rides along only as a debugging hint and
  is trimmed to 80 bytes.

Deliberately NOT trimmed: the auto-caption output, which must stay exactly
"subtitled_<ts>_<clip filename>" because the subtitle modal's walk-back and
_canonical_clip_file both reconstruct the clean original from it. Length is
bounded upstream instead; a legacy clip that predates the budget raises
OSError 36, which the existing guard turns into "ship it uncaptioned".
2026-07-26 20:59:04 +02:00
victormanuel.caverogracia
28a1f6aef2 Remove Plausible analytics (migrated to OpenPanel) 2026-07-26 20:39:28 +02:00
juancarlos.cavero
f0ecb0d078 fix(reframe): stop the switch cooldown from failing open
The cooldown that keeps the camera from swinging between subjects only applied
when the active speaker happened to be detected in the current frame. If they
were missing — a blink, a head turn, one motion-blurred frame — the guard fell
through and switched immediately, so it only ever held when it wasn't needed.
Measured on a 12s clip: 3 of 7 target switches jumped the cooldown this way.

Now the cooldown holds regardless: it returns the active speaker's box when
visible and None otherwise, and the caller only calls update_target() on a
truthy box, so the camera keeps its target and finishes whatever move it was
making. The hold stays bounded by the cooldown, so a subject who really did
leave the shot is still released once the window expires.

Measured on the same clip: cooldown bypasses 3 -> 0, target switches 7 -> 5.

This does NOT by itself calm the camera down — reversals stayed at 13 over 12s.
The dominant driver is target jitter (p90 of 496px per update, 15 of 67 updates
alone exceeding the 101px safe zone) plus faces losing their identity on
re-detection, both of which need tuning against representative footage rather
than a screen recording.
2026-07-26 11:44:27 +02:00
juancarlos.cavero
fd7a2b2cd9 feat(subtitles): let users remove the default captions
Clips now ship captioned, and the modal could only restyle — there was no way
back to a clean clip, so anyone who didn't want captions was stuck with them.

Adds POST /api/subtitle/remove, which points the clip at its un-captioned
original. No re-encode and no quota: the pipeline already keeps the clean file
next to the derived subtitled_<ts>_ one, so removing is choosing the other file.
It reuses the burn path's walk-back, so it undoes any number of restyles, and
running it twice is a no-op.

Verified end to end: auto-caption, restyle (burning from the clean file rather
than stacking a second layer), remove, and remove again.
2026-07-25 17:48:08 +02:00
juancarlos.cavero
a2237d07d3 feat(clips): ship every clip captioned by default
Captions are what make a short readable with the sound off, and 91% of
delivered clips had none (35 subtitle jobs against 380 process jobs in the
25-jul-2026 prod audit) because they were opt-in behind a modal. Now every clip
comes out captioned and the modal becomes a re-style, not a discovery.

The look was picked by rendering four candidates on a real clip and comparing
them: white Anton uppercase, yellow active word, heavy black outline, gentle
pop. Yellow because it is the one colour that almost never occurs in footage,
so the active word reads instantly on any background. The base text stays fully
opaque — dimming it, which several caption tools do, tested worse over bright
scenes. Captured in AUTO_CAPTION_STYLE so there is one place to change it.

Two fixes fell out of rendering it for real:
- Captions sat at MarginV=25 (8.7% of frame height), underneath TikTok's and
  Reels' own bottom chrome. Raised to a documented SAFE_MARGIN_V of ~15%, now
  a parameter rather than a hardcoded literal.
- The pop effect scaled the active word 75->112, wide enough that any frame
  caught mid-animation read as a sizing bug. Softened to 90->108.

Wiring follows the convention already used by /api/subtitle: the captioned file
is written as subtitled_<ts>_<clip>.mp4 next to the untouched original, so
re-styling from the modal replaces the captions instead of burning a second
layer over them (its existing walk-back resolves this unchanged). The places
that rebuild the canonical clip name from disk — restore after a restart, the
project reopen, the download bundle — now resolve through _canonical_clip_file
so a redeploy cannot silently serve the uncaptioned version. R2 uploads follow
video_url, so the durable library gets the captioned clip too.

Captions are applied after the watermark, never before, and any failure is
swallowed: a caption problem must not cost the user a clip they already paid
for. Silent videos have no transcript and are skipped. AUTO_CAPTIONS=0 is the
rollback lever.

Verified end to end in the container: burn produces the derived file, the app
resolves to it, the modal walks back to the clean original, silent input ships
uncaptioned, the kill switch works, and the newest styling wins.
2026-07-25 17:42:08 +02:00
juancarlos.cavero
a793e02ddf fix(subtitles): stop charging quota for burning captions
Captions are table stakes for short-form — a clip without them barely works on
any platform — but every burn cost 2 minutes, 10% of the free monthly quota,
roughly what generating the clip cost in the first place. People skipped them:
only 9% of delivered clips had captions in the 25-jul-2026 prod audit (35
subtitle jobs against 380 process jobs).

The charge never matched the work. The normal path reads the transcript already
stored in metadata.json and runs one short FFmpeg pass — measured at 4s on CPU
for a 12s clip, 1-2s on the GPU. Charging 120s of quota for that is ~30x the
compute, and it was invisible in the UI, so users were drained without being
told. The endpoint is already gated by require_managed_entitlement, so the
charge was never what bounded abuse.

Dubbed clips keep the charge: subtitling them re-runs Whisper over the
translated audio, which is real work. The rule lives in cloud.config next to
the constant so it stays testable without importing app.

Also short-circuit reserve_managed_action on a zero-minute action rather than
writing a 0-minute ledger row on every call.
2026-07-25 17:16:59 +02:00
juancarlos.cavero
98fd35130c fix(clips): deliver 1080x1920 instead of inheriting the source height
An audit of 45 real user clips pulled from R2 on 25-jul-2026 found 86% below
1080 wide, 80% of them exactly 406x720 — well under what TikTok, Reels and
Shorts expect, so the platforms re-encode an already soft image. Two causes,
one on top of the other:

- The download capped format selection at 720p whenever PROXY_URL was set. The
  cap exists to control paid-proxy bandwidth, but it was decided once from
  `_proxy` rather than per attempt, so it also capped the DIRECT attempt — the
  one that costs nothing and, with DIRECT_FIRST=1, serves most downloads. It is
  now chosen per attempt: direct pulls up to 1080p, proxied stays at 720p.
- The reframe set out_h = orig_h, so a 720p source could only ever produce a
  406x720 crop. `delivery_size()` now upscales to a 1080-wide floor and leaves
  anything already above it untouched — a 4K source still delivers 1216x2160,
  so no one loses resolution they supplied.

Applied to the v1 fallback too: an emergency render is still the clip the user
posts. Its frame loop already resizes to the target dims, so only the target
changed.

Crop geometry is unaffected — SmoothedCameraman derives the crop from the source
dimensions and never reads the output pair, which the call site now documents.

Verified end to end: a 1280x720 source that previously rendered 406x720 now
renders 1080x1920, correct aspect, no distortion.
2026-07-25 17:09:03 +02:00
juancarlos.cavero
5b5d3d2306 fix(billing): stop stranding customers whose payment failed
A declined card left the account in a state with no way out. `past_due` grants
no minutes, so the metering layer resolved the user to the free plan — which
meant /api/me reported status=null, the account page swapped "Manage billing"
for "Upgrade" (hiding the only button that fixes a card), and the checkout guard
then rejected the upgrade with a 409 that every call site swallowed into a
generic "Could not start checkout." Silently free, unwarned, unable to pay.

Found on 25-jul-2026 in prod: 14 subscriptions in this state, all first charges
that failed when the (now retired) 3-day trial ended. The trial is gone, but the
trap is not — a renewal failure or an abandoned 3DS payment reproduces it.

- metering: split `_subscription_row` (raw) from `_active_subscription`
  (entitling), and expose both on the balance. Entitlement logic is unchanged.
- /api/me: report status/interval from a row needing attention when no
  subscription entitles, plus `has_billing_account` to route the portal button.
- checkout: drop `incomplete` from the blocking states. Stripe collects nothing
  on it and expires it within 24h, so blocking only stopped the user's retry.
  Give past_due/unpaid a message that names the problem and the fix.
- account page: explain the failed payment inline with a link to the portal
  instead of showing a bare "past_due" chip, and keep the portal reachable for
  any Stripe relationship, live or broken.
- api client: throw a typed ApiError carrying the server's detail so callers
  stop replacing real, actionable messages with generic copy.

Verified against a real DB: past_due stays blocked but visible and fixable,
incomplete can retry, canceled is silent and can subscribe again.
2026-07-25 15:14:15 +02:00
juancarlos.cavero
c88239921e feat(conversion): vender también en los momentos buenos, no solo en el muro
Hasta ahora el único camino al upgrade era fallar contra la cuota. Tres
momentos nuevos, todos con el mismo mensaje ya validado (watermark +
caducidad 7d + minutos):

- Resultados (pico de satisfacción): banner para usuarios free junto a
  sus clips recién generados — "Like these clips? Keep them forever →" —
  que abre la modal de upgrade en modo 'upsell' (copy adaptado: aún
  tienen minutos, se vende permanencia y limpieza, no "te quedaste sin").
- Medidor del header: para free abre la modal de upgrade en vez de ir a
  account — antes no existía ningún camino visible a los planes desde el
  dashboard sin fallar primero.
- Email "tus clips se borran mañana": warn_free_expiring() en el sweeper
  avisa el día 6 de los 7 de retención free, con descarga o upgrade como
  salidas. Aversión a la pérdida honesta: la fecha es real y hoy se
  borraba en silencio, lo que no convertía a nadie. Dedupe en memoria
  (peor caso tras restart: un duplicado).

Eventos UpsellModalSeen/UpsellModalCheckout separados de los del muro
para medir cada momento por su lado.

Verificado: lógica del aviso probada contra la DB local (clip de 6.5d
avisa, el de 8d ya purgeable no, segundo pase no duplica); 141 tests y
build del dashboard en verde.
2026-07-25 02:27:34 +02:00
juancarlos.cavero
95a9a5ff1e feat(conversion): vender el plan (no top-ups) en el momento del muro de cuota
De 76 impactos del muro 402 en 72h solo 4 llegaron a checkout y la única
compra fue un top-up: la modal antigua ofrecía packs de minutos sueltos
como opción principal, el upgrade a plan era un párrafo NO clickable y
un StarBanner empujaba a GitHub en pleno momento de compra.

Nueva modal (mismo fichero/props, cero cambios en App.jsx):
- Starter destacado + Creator al lado como ancla de precio; bullets del
  valor real de pagar: 5x/15x minutos, sin watermark, clips permanentes
  (los free caducan a 7 dias) y prioridad de cola sobre free — todo
  cierto, sin escasez inventada ni cuentas atras falsas.
- Copy goal-gradient con los datos del 402: "this video needs X min and
  you have Y left — upgrade and it starts processing right away".
- "cancel anytime" como reversion de riesgo; top-ups relegados a un link
  discreto que expande; StarBanner fuera.
- Eventos QuotaWallSeen / QuotaWallCheckout para medir la conversion del
  muro, que hasta ahora era invisible.

El email de sin-minutos replica el mismo mensaje (perdida + plan concreto
+ CTA unico) y por fin deja rastro en logs al enviarse.

Verificado end-to-end en local: usuario free con cuota agotada via DB,
402 real de /api/process, modal con datos reales y packs expandibles.
2026-07-25 02:14:58 +02:00
juancarlos.cavero
77905a9790 fix(gemini): distinguir bloqueo de contenido de fallo transitorio
La alerta del 23-jul (5/12 jobs, "empty response body") no era la API
fallando: un vídeo subido (stand-up con contenido explícito) devuelve
prompt_feedback.block_reason=PROHIBITED_CONTENT en ~300ms, de forma
determinista — verificado con la transcripción real, y BLOCK_NONE en
safety_settings NO lo levanta (es el filtro de política de Google, no
configurable). Reintentábamos 3 veces algo imposible, el error parecía
un fallo nuestro, y el usuario reintegró el mismo vídeo varias veces
inflando la tasa de fallos.

- gemini_worker: GeminiBlockedError + raise_if_blocked() (block_reason
  del prompt y finish_reason SAFETY/PROHIBITED_CONTENT/... del candidato).
- main: _run_gemini_stage falla rápido sin reintentos ante bloqueo (0.5s
  vs ~15s) y propaga el motivo real hasta el log del job en ambas vías
  (transcript y visión); ya no se convierte en el genérico "no clips".
- alerts: categoría propia "blocked content (user video)" para que la
  alerta no se lea como caída del servicio.
2026-07-24 00:37:14 +02:00
juancarlos.cavero
5f7bf42721 fix(subtitles): empaquetar fuentes reales para que el estilo elegido se aplique (#57)
La imagen Docker solo traía DejaVu: todas las fuentes que ofrece el modal
(Verdana, Arial, Impact, Helvetica, Georgia) caían en silencio al fallback
de fontconfig, así que el burn salía siempre con la misma letra por mucho
que el usuario cambiara los ajustes — mientras el preview del navegador,
que usa las fuentes del sistema del usuario, prometía otra cosa. Reportado
en la issue #57 como "captions coming out wrong / settings set to default".

- Dockerfile: fontconfig + fonts-liberation (equivalentes métricos de
  Arial/Helvetica/Verdana y Georgia) y registro de las fuentes del repo.
- fonts/Anton-Regular.ttf (OFL): sustituta estándar de Impact.
- fonts/openshorts-fontmap.conf: alias fontconfig nombre-de-UI -> fuente real.
- subtitles.py: fontsdir en los filtros subtitles/ass para que libass vea
  las fuentes del repo aunque el fontconfig del sistema esté pelado.

Verificado en contenedor: fc-match Impact->Anton, Verdana->Liberation Sans,
Georgia->Liberation Serif, y dos burns reales muestran letra distinta por
elección (antes idénticas). El backend de /api/subtitle ya aplicaba bien
los estilos en pasadas repetidas (walk-back correcto, sin doble subtítulo).
2026-07-23 15:55:36 +02:00
juancarlos.cavero
1c6431e8a0 test(ci): saltar los tests que importan main/app en el CI mínimo
El CI instala solo pytest+pillow+httpx+pydantic+sqlalchemy. test_gemini_retry
importa main (cv2/torch) y test_job_error_text importa app (dotenv/fastapi),
que faltan → ModuleNotFoundError en la colección. importorskip los salta en
CI y los corre entero en el contenedor/local donde sí están las deps.
Verificado en un venv réplica del CI: 125 passed, 2 skipped.
2026-07-23 11:40:05 +02:00
juancarlos.cavero
6dd3ef8117 fix(clips): +faststart en el render final para que el navegador reproduzca
El concat de reframe_v2 (el camino real de prod) y el merge de
process_video_to_vertical escribían el moov atom al final del MP4. Sin
faststart el <video> del navegador no puede empezar a reproducir hasta
descargar el fichero entero → el preview se queda con el spinner eterno.
Descargar el clip funcionaba (por eso pasó desapercibido), pero
previsualizarlo en la app no.

Verificado con ffprobe: antes moov al 98%, ahora al frente. Bug
preexistente, no introducido por el scrub de metadata.
2026-07-23 11:11:05 +02:00
juancarlos.cavero
6ea46ca5d2 feat(clips): borrar la metadata heredada del source en los clips finales
Los clips arrastraban el handler de stream "ISO Media file produced by
Google Inc." del vídeo original de YouTube: ffmpeg copia la metadata del
input por defecto, así que sobrevivía a todos los reencodes y acababa
publicado en la red social. Rastro innecesario del origen.

Se añade METADATA_SCRUB en ffmpeg_utils y se aplica en cada productor de
fichero final: el concat de reframe_v2 (el camino real de prod), el merge
de process_video_to_vertical, el passthrough horizontal, el watermark, y
los reencodes de subtítulos/hooks/editor.

Detalle que costó verificar: -map_metadata -1 global NO basta — el
handler_name a nivel de stream sobrevive a un -c copy. Hacen falta los
especificadores por stream (-map_metadata:s:v -1 -map_metadata:s:a -1);
son inofensivos cuando falta un stream. Verificado con ffprobe sobre un
clip real del pipeline completo: sin rastro de Google.

No promete boost de alcance (eso lo decide el fingerprint de contenido,
no los tags del fichero); es higiene y quitar el rastro del origen.
2026-07-23 01:34:59 +02:00
juancarlos.cavero
be4510aa43 fix(jobs): reintentar los fallos transitorios en vez de tumbar el job
Tres jobs de prod murieron el 22-jul porque Gemini contestó 200 con el
cuerpo vacío. Eso revienta al parsear, no al llamar, así que se escapaba
del bucle de reintentos: un parpadeo de la API bastaba para perder el job.
El mismo payload funciona 5 de 5 al reintentarlo.

- gemini: el parseo pasa a estar dentro del bucle, y la respuesta vacía o
  no parseable cuenta como error transitorio.
- descarga: reintento del 403 de YouTube, que casi siempre viene de que el
  proxy residencial rota la IP de salida entre la extracción y la descarga
  (3 de 62 descargas en 24h).
- se elimina el fallback de reframear el vídeo entero: no escribía
  metadata.json, así que app.py marcaba el job como fallido igualmente
  después de gastar GPU en un render que nadie llegaba a ver.
- alertas: la clasificación lee ahora las líneas de error del log en vez
  de las 10 últimas, que eran ruido de progreso y hacían culpar al
  subsistema equivocado (un parpadeo de Gemini se reportó como ffmpeg).
2026-07-23 00:24:31 +02:00
juancarlos.cavero
ed3bdc45a8 feat(download): intento directo sin proxy antes del fallback de pago (DIRECT_FIRST=1)
Validado en prod 21-jul: con cookies + PO token bgutil la IP del servidor
descarga directa de YouTube (~110 MiB/s); sin cookies YouTube la bloquea
tras la primera petición. El proxy residencial queda como fallback y
PROXY_BYTES solo se emite cuando el intento ganador usó el proxy.
2026-07-21 22:35:37 +02:00