Commit graph

433 commits

Author SHA1 Message Date
juancarlos.cavero
0bfe27561d Merge PR #70 (manual per-scene reframing) onto current main
Conflicts were the parallel override parameters: render_clip /
process_video_to_vertical / reframe_v2.render / perform_recut now carry
BOTH force_strategy (whole-clip framing, main) and crop_overrides
(per-scene manual framing, PR #70). The v1-fallback safety net now also
raises for force_strategy, which had the same silent-revert hole the PR
fixed for crop_overrides.
2026-08-19 12:01:02 +02:00
juancarlos.cavero
3cff7e8cd6 fix(editor): explain why cuts are limited when the source is gone
Addresses the UX half of #67: with no retained source the editor clamps
cuts to the original clip range but never said why, reading as a bug. A
note in the segments panel now names the reason and that newly processed
videos keep their source.
2026-08-19 10:50:22 +02:00
juancarlos.cavero
3790c65851 fix(subtitles): honor user-edited caption text on the server render path
Fixes #69. The subtitle modal lets the user edit the caption text, but the
edits only traveled through the in-browser Remotion path; the FFmpeg path
(taken by every karaoke style and by any clip with server burns, i.e. all
clips with default captions) sent style params only, so the server
regenerated from the stored transcript and silently discarded the edits.

/api/subtitle now accepts an optional 'words' list (clip-relative ms, the
same shape the /transcript endpoint serves) and builds a synthetic
transcript from it, so both the SRT and karaoke ASS generators burn the
edited words verbatim. Words get Whisper's leading-space convention so the
block collector keeps their boundaries. The modal sends them only when the
text actually differs, and never on bulk apply-to-all (edits are per-clip).

Verified live: an edited 5-word line burned exactly as typed, correctly
grouped into blocks.
2026-08-19 10:50:22 +02:00
Tulio Vianna
b92012d824 feat: manual reframing, per scene
The reframe engine picks the crop automatically and is right most of the
time. When it is wrong it is badly wrong, and there was no way to say
"no, frame it here".

The unit is the SCENE, not the clip. A podcast cuts between a fixed close
camera and a fixed wide one, and the right crop differs per camera; scene
boundaries already are those camera changes. Scenes the user never touches
keep the automatic camera, so correcting one bad shot cannot spoil the
shots the tracker got right.

Backend:
- reframe_v2.apply_crop_overrides() replaces a scene's slice of the camera
  trajectory with a constant and forces it to TRACK, so a scene the
  classifier had sent to GENERAL comes back to a vertical crop. It runs
  after every automatic pass, including the ALTERNATE writes, so a manual
  choice always wins.
- A scene can also be split by hand: the override writes straight into
  `splits`, which means the user can stack a scene the detector never
  proposed, with no dependency on SPLIT_LAYOUT being enabled.
- GET /api/clip/{job}/{i}/scenes returns the scenes with a frame from the
  UNCROPPED cut plus a light preview with audio, and suggests a centre from
  the largest face in each shot.
- POST /api/clip/reframe re-renders with the clip's cut untouched. It is
  deliberately separate from /api/clip/rerender: a scene index only means
  something against a given cut, so letting framing ride along with a trim
  save would move every override onto the wrong shot.
- render_clip raises instead of falling back to the v1 engine when manual
  framing is present, since v1 ignores it and would silently return an
  automatically framed clip.

Frontend:
- ReframeEditor lists the scenes, each with the source frame, a draggable
  9:16 window, and a play button that plays that scene from the preview so
  the user can hear who is talking before choosing.
- Saved overrides are loaded when the editor reopens. Without that the next
  save would discard every earlier adjustment, because a re-render rebuilds
  from source using only what it receives.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 22:33:52 -03:00
juancarlos.cavero
9c220efddb feat(editor): manual framing override (auto / full frame / track subject)
The scene classifier only counts faces, so a screencast-style video with a
presenter in frame gets TRACK and the crop eats the slide (the SCREENCAST/
WIDE detectors sit behind the opt-in layouts=auto flag). The clip editor now
has a framing selector that pins every scene's layout: 'full' renders the
whole source frame (WIDE: no side-crop, blurred bands), 'track' forces the
subject-tracking crop, 'auto' returns to the classifier.

Plumbed as force_strategy through reframe_v2.render -> render_clip ->
perform_recut -> /api/clip/rerender (and the recut_clip MCP tool). A
non-auto choice always re-reframes from the retained source (409 without
it) and persists in the clip's recipe, so later plain trims inherit the
look instead of silently reverting; an explicit 'auto' resets it.

Verified live: framing=full on a TRACK-cropped clip re-rendered with the
full frame visible edge to edge (125s source path), and the editor reopens
with the persisted choice preselected.
2026-08-19 01:06:48 +02:00
juancarlos.cavero
4611ca119b fix(generate): scale scoring windows with the requested clip band
The detail prompt keeps clips inside their candidate window, so the default
90s scoring windows silently capped user-requested long clips (a 60-90s band
barely fit, anything above did not). Windows now grow to 1.5x the requested
max length; the default band keeps the exact old behavior.
2026-08-18 19:41:15 +02:00
juancarlos.cavero
100fa583a1 Merge feat/clip-editor: per-clip EDL editor + manual generation controls (PR #62, discussion #65) 2026-08-18 19:27:49 +02:00
juancarlos.cavero
b81125c572 feat(generate): manual clip count and duration controls (discussion #65)
/api/process (and the process_video MCP tool) now accept optional
target_clips (1-15) and clip_min_seconds / clip_max_seconds (5-180),
surfaced in the dashboard as a collapsed 'advanced options' section.
Blank means the AI decides, keeping the default request byte-identical.

Plumbed through the same env overrides the A/B harness already reads:
CLIP_TARGET_MIN/MAX (existing) and a new clip_duration_bounds() in
clip_selection.py backing CLIP_MIN_SECONDS/MAX_SECONDS. The detail and
visual prompts take the band as template placeholders instead of the
hardcoded 15-60, and word-snapping enforces the same bounds. All three
knobs are honest targets, not guarantees: the model still returns fewer
clips when the material doesn't hold them, and the UI copy says so.

Verified live: target_clips=2 + band 8-15s on the demo video returned
exactly 2 clips of 13.3s and 13.7s (the uncontrolled run gave one 41.7s
clip); out-of-range values 400 with a named reason.
2026-08-18 19:21:42 +02:00
juancarlos.cavero
d1bf36c666 fix(dashboard): recut duration display and stale durable URL
- A recut clip's start/end are the covering source range, so end - start
  showed a 20s two-segment clip as minutes long; duration now sums the
  recipe segments when present.
- Drop the clip's durable R2 URL after a rerender: archive_clip_edit
  deletes the superseded object, so the stale URL would 404 as the
  playback fallback.
2026-08-18 15:26:45 +02:00
juancarlos.cavero
a0e25828fd fix(cloud): archive clean canonical clips so restored projects stay editable
The clip editor's fast path (and /api/subtitle re-styles) cut from the
clean canonical file, but archive_job only uploaded the served derivative,
so every project restored from R2 after a redeploy 409'd on rerender even
for in-range segments. Archive the clean canonical alongside the served
file; restore already downloads everything under the job prefix. The
free-retention purge now deletes the whole job prefix so these extra keys
(and previously leaked derivatives) can't become orphans.
2026-08-18 15:26:45 +02:00
juancarlos.cavero
e381d21b54 fix(editor): serialize rerenders per job and re-validate after snapping
- Per-job asyncio lock around /api/clip/rerender (same pattern as
  _restore_locks): concurrent saves raced on the metadata.json
  read-modify-write, with the last writer silently reverting the other
  clip's recipe and video_url.
- Re-run normalize_segments after snap_to_words + clamp: a segment fully
  outside the canonical range used to clamp to an inverted (end < start)
  window that passed within_range and died in ffmpeg as a 500; it is now a
  clean 400.
2026-08-18 15:26:45 +02:00
juancarlos.cavero
18654eabf6 fix(editor): harden the recut engine
- Add METADATA_SCRUB + '-movflags +faststart' to the cut and concat
  commands: a fast-path recut IS the delivered file, and without a fronted
  moov atom the browser preview hangs (same invariant as every other
  final-artifact producer in the repo).
- Unique per-invocation temp names (uuid token) for part/list files and a
  uuid suffix on the output name: two concurrent recuts in one job dir no
  longer overwrite or delete each other's intermediates, and same-second
  saves of one clip no longer collide on the output filename.
- 1800s timeout on ffmpeg runs (matching apply_watermark) so a hung render
  can't pin an executor thread and its quota reservation until restart.
2026-08-18 15:26:44 +02:00
juancarlos.cavero
5b4f5b2891 fix(digest): harden daily digest after code review
- Retry the 06:00 send in place (6x / 5 min) instead of silently skipping
  the day when a DB blip or Telegram outage lands on the send minute; the
  digest path now uses send_telegram(raise_errors=True) so failures are
  visible to that retry, and send_telegram checks the HTTP status.
- Filter Stripe lines by processed_at, not the Stripe-side created stamp
  that survives delivery retries and could land inside an already-digested
  window.
- Drop invoice.payment_succeeded (near-alias of invoice.paid; counting both
  double-reports payments) and the Subscription.created_at count (upserts
  hide re-subscribing churned users) — customer.subscription.created events
  cover new subs correctly.
- Keep a strong reference to the digest task so it can't be GC'd mid-sleep.
2026-08-18 14:53:31 +02:00
juancarlos.cavero
9a4439af48 feat(alerts): daily Telegram ops digest
One message per day at 06:00 UTC with signups, processing activity (users,
jobs, minutes, refunds), clips created, new subscriptions and notable Stripe
events, all computed from the DB at send time so redeploys lose nothing.
Replaces the per-event free-tier pings removed in the previous commit.
2026-08-18 14:40:55 +02:00
juancarlos.cavero
cf08a9671b chore(alerts): drop free-tier 'First clips!' Telegram notifications
Every new free user's first job fired a Telegram message, which at current
signup volume is pure noise. Clip-activity notifications now fire only for
paid users' jobs; the activation signal lives in analytics, not the ops chat.
2026-08-18 14:32:24 +02:00
juancarlos.cavero
e4331467e5 fix(auth): harden MX verification after code review
Review findings on the MX-gate commit, addressed:

- Rate limits now run BEFORE the DNS work, and the attempt row is
  inserted before the MX gate, so rejected junk-domain floods count
  toward both limits instead of getting unlimited free DNS lookups.
- Existing accounts bypass the MX gate: it protects sign-up only, so a
  domain whose MX later matches the disposable list can't lock an owner
  out of their account.
- RFC 5321 implicit MX now also checks AAAA (IPv6-only mail domains
  were falsely rejected).
- Error-derived verdicts cache for 60s instead of 1h: a transient
  NXDOMAIN no longer pins a lockout, a resolver blip no longer
  whitelists a domain for an hour.
- One shared resolver with an LRU record cache (was: new resolver +
  resolv.conf read per lookup); verdict cache evicts FIFO instead of
  full clear.
- MX blocklist moved to disposable_mx.txt, same loader and ops workflow
  as disposable_domains.txt (the two lists were already drifting).
- Both rate-limit counts merged into one FILTER query; distinct 429
  message for the per-IP limit (shared-NAT lockouts diagnosable).
- Index on (request_ip, created_at) + 30-day token purge in the
  retention sweeper. NOTE: schema is create_all-only, prod needs:
  CREATE INDEX IF NOT EXISTS ix_magic_ip_created
    ON magic_link_tokens (request_ip, created_at);
2026-08-13 10:07:20 +02:00
juancarlos.cavero
a76decd56f feat(auth): verify email domain MX before sending magic links
Bot sign-ups with rotating temp-mail domains (onldm.net -> 10minutemail's
SMTP) and nonexistent addresses were bouncing every magic link back into
the support inbox and hurting sender reputation.

- email_policy.mx_verdict(): resolve the domain's MX (A fallback per RFC
  5321) and reject when nothing can receive mail or when the MX target
  belongs to known disposable-mail infrastructure - catches the rotating
  front domains the static blocklist can't keep up with. Cached per
  domain, fails open on resolver trouble.
- auth: per-IP rate limit on magic-link requests (bots rotate addresses,
  not IPs).
- blocklist: add onldm.net; pin dnspython (already transitive via
  email-validator).
2026-08-13 01:03:05 +02:00
juancarlos.cavero
ab86e41846 feat(skills): cross-agent metadata for the Agent Skills ecosystems
The skill already follows the open standard; this adds the OpenClaw
block (emoji, primaryEnv) and the Hermes block (category, tags) plus
version and homepage, all ignored by agents that don't read them.
README gains the per-agent install commands: copy for Claude Code,
GitHub-direct for Hermes, ClawHub for OpenClaw.
2026-08-06 09:34:07 +02:00
juancarlos.cavero
46c61e407b feat(mcp): list_clips renders as an MCP App clip picker in UI-capable clients
New mcp_ui module holds the template: preview each 9:16 clip inline,
select the keepers and publish them via publish_clip from inside the
conversation. One template, three data paths, because the ecosystem has
not converged: baked-in JSON on the per-call embedded resource, the
ChatGPT Apps window.openai bridge, and the MCP Apps ready/render-data
postMessage handshake. Titles are JSON-escaped so a clip name cannot
break out of the script tag, and the template is fully inline because
host CSPs block external fetches.

The server grows resources/list, resources/read and the resources
capability; list_clips declares the template under both _meta.ui
.resourceUri and openai/outputTemplate. Non-UI clients see the same
text and structured content as before; the extra content entry is
spec-tolerated. The unknown-method protocol test moves off
resources/list, which is now a real method.
2026-08-05 23:59:02 +02:00
juancarlos.cavero
40f530f9aa feat(landing): surface the CLI wherever the agent surface is described
Feature card, FAQ answer, crawler fallback, /mcp and the automation
page all name pip install openshorts alongside MCP and the REST API.
2026-08-05 15:04:39 +02:00
juancarlos.cavero
78deea2b15 feat(agents): zero-dependency CLI and agent skill over the same API
pip install openshorts / uvx openshorts: process, status --watch, clips,
quota and publish, all against the REST surface the dashboard and MCP
already use, so nothing can drift. Auth and target via env vars; the
self-hosted case is the same binary pointed at localhost with no key.

skills/openshorts/SKILL.md teaches skill-capable agents the async loop
(quota, submit, signed webhook, publish) including the self-host 401/404
convention and the rights acknowledgement. The skills/ ignore narrows to
third-party installs so the published skill is versioned. README wires
up CLI, skill and the n8n example under the automation section.
2026-08-05 14:52:44 +02:00
victorcavero14
b884131639 feat(editor): clip editor frontend — ClipEditor overlay wired into results
- ClipEditor.jsx: per-clip edit overlay driving the /edl + /rerender backend
- App.jsx: editingClip state, handleClipRerendered syncs results, reopened
  project state and per-clip edit state after a recut (burned layers reset)
- ResultCard.jsx: "edit clip" entry button (Scissors), layout tweak
- recut.py: write absolute paths in the concat list — the demuxer resolves
  relative entries against the list file's dir, not the process cwd

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-05 12:03:15 +02:00
victorcavero14
d9b15b4328 feat(editor): per-clip EDL backend — recut engine, /edl + /rerender endpoints, MCP tool
Every clip now exposes its recipe (which source segments it was cut from)
via GET /api/clip/{job}/{i}/edl, and POST /api/clip/rerender re-renders it
from an edited segment list: fast path recuts from the already-reframed
canonical file, source path re-reframes from the retained source
(--keep-original now passed for URL jobs). Captions/subtitles/transcript
remap piecewise through recut.virtual_transcript for multi-segment clips.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-05 11:03:15 +02:00
juancarlos.cavero
d566b1a9b7 docs(examples): importable n8n workflow for the API + webhook loop
Form in, signed webhook out, one item per finished clip. The existing
community template (203 views) wires Whisper and Gemini directly and
never calls the OpenShorts API; this is the version worth publishing on
creators.n8n.io, kept in-repo so the template and the API cannot drift.
2026-08-04 18:58:47 +02:00
juancarlos.cavero
9f3bedecde feat(seo): five demand-backed pages + honest agent-access comparison on /mcp
New static pages, each re-housing demand GSC already shows landing on the
homepage: no-watermark clip generator (the AI-answer gap: unwatermarked
free clipping only exists self-hosted), open-source AI video generator
(splits the text-to-video intent honestly), podcast-to-shorts (the SPLIT
layout as the capability no competitor page can show), YouTube-to-Shorts
converter (link import is free here, paid at Opus Clip), and an
automation recipe page (API + signed webhooks + n8n shape).

/mcp gains a checked comparison table: Opus Clip shipped MCP in July
2026, so the claim that survives is flat-minute billing and self-hosted
agent access with no meter, not MCP existence. All competitor claims
carry checked dates.
2026-08-04 17:58:25 +02:00
juancarlos.cavero
4c94c29964 feat(seo): close the internal-link gaps around the static cluster
The rendered React landing had zero links to the static SEO pages, so
Googlebot's rendered homepage dropped the whole cluster; the static
pages' nav and footer missed /mcp and the /alternatives hub; and the
crawler fallback missed both too. Every surface now links the full set
with descriptive anchors.
2026-08-04 14:19:28 +02:00
juancarlos.cavero
cc8fa54ffa feat(pricing): MCP + API access named where buyers compare plans
A bullet on every plan card, the always-on framing in 'included in
every plan', and a billing FAQ answering the question that actually
blocks a purchase: API calls draw from the same minutes, nothing extra
to buy, free plan included.
2026-08-04 00:24:50 +02:00
juancarlos.cavero
626d4b1917 fix(test): pin a dummy Gemini key so the webhook SSRF test runs the SSRF branch in CI 2026-08-04 00:09:03 +02:00
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