Commit graph

317 commits

Author SHA1 Message Date
juancarlos.cavero
05c0238cc0 fix(api): compute social impressions from the profile-scoped post cache
Upload-Post's /total-impressions/{profile} echoes the requested profile
but returns account-wide numbers — a profile with zero posts got 85K
Instagram impressions — which for managed users leaks other tenants'
aggregates into the dashboard card and the analytics API. Aggregate the
post-analytics cache instead, which is correctly scoped by ?user=, and
keep the same response shape (total_impressions + per_platform).
2026-08-21 19:49:09 +02:00
juancarlos.cavero
cb1eecaa34 feat(dashboard): post analytics card + connect entry in profile selector
Account page gains a 'Your posts' card: last-30-days impressions with
per-platform split and the top 3 posts by views, backed by the new
analytics endpoints. Hidden for free users (402) and until data loads.

The header profile selector was a no-op for managed users (exactly one
profile, nothing to switch) while displaying greyed-out networks with
no way to connect them — it now ends in a Connect / manage accounts
action that opens the branded Upload-Post connection page.
2026-08-21 19:16:53 +02:00
juancarlos.cavero
6f76e875cd feat(examples): n8n Content Machine template + webhookId fix
New openshorts-content-machine.json: daily channel-RSS watcher (one
video per day, new upload first then back catalog), clips delivered to
Telegram with approve/skip buttons, approved clips drip-scheduled via
/api/social/post, weekly analytics digest from the new endpoints. A 402
pauses the machine with a Telegram notice and leaves the video
unmarked so the next day retries it.

Both templates now carry webhookId on webhook-based trigger nodes:
without it n8n imports the node but never registers the webhook, so
every incoming call 404s. Found by importing and executing the
workflow against a live n8n.
2026-08-21 19:16:53 +02:00
juancarlos.cavero
be5b7276c2 feat(api): read-only social analytics proxies over Upload-Post
GET /api/social/analytics (profile totals), /analytics/posts (per-post
cached metrics) and /analytics/impressions (windowed totals). Managed
users are locked to their own profile and rate-limited to 60/h in a
bucket separate from the metering probes; cloud without a plan gets a
clean 402 no_plan instead of a misleading missing-header 400. BYOK
keeps its own key and picks the profile with ?user=.
2026-08-21 19:16:53 +02:00
juancarlos.cavero
8fb5e3b7b6 fix(editor): hide the word-boundary hint when the job kept no transcript
A silent/visual-only job has no words to click, so 'CLICK A WORD, THEN
SET A BOUNDARY' sat right above 'this job kept no transcript'.
2026-08-21 15:17:44 +02:00
juancarlos.cavero
4a71d66066 fix(dashboard): guard the synced-playback seek against a non-finite time
Found while browser-testing the editor: a clip without a start yet makes
ResultCard emit onPlay(NaN), and assigning that to currentTime throws in
a mount effect, taking the whole tree down to a black screen.
2026-08-21 04:49:28 +02:00
juancarlos.cavero
0b59047422 feat(dashboard): social-connect nudge at the results peak
Only 2.7% of cloud users who pass through the social flow ever connect a
network (146 of 5,406 Upload-Post profiles), yet publishing from the app
is the strongest retention loop we have. Show a dismissible banner right
when the clips appear - the moment with the best odds - prompting managed
users with no connected network to open the hosted connect page.

Instrumented like the other conversion moments: SocialNudgeSeen (once per
job), SocialNudgeConnect, SocialNudgeDismissed (persisted in localStorage,
never shown again). Hidden automatically once any network is linked.
2026-08-21 04:36:05 +02:00
juancarlos.cavero
9d18520c2e fix(editor): four UX corrections from issue #73
- The clip track's scale is now the rendered length instead of the
  current total, so trimming a segment visibly shortens its bar; before,
  a single-segment clip always filled 100% of the track and dragging its
  handle appeared to move nothing.

- Playback boundaries are enforced by a per-frame rAF loop instead of
  timeupdate (~4Hz), which let the preview overshoot a trimmed endpoint
  by up to 250ms — the exact frame is what an end trim is judged
  against. Hitting an edge also snaps currentTime back onto it.

- The transcript header now offers 'segment starts/ends here' actions on
  the selected word, where the eye already is when choosing a cut point
  from the text.

- Closing the editor mid-render is allowed and explained: the request
  keeps running and onRerendered (functional setState in App) updates
  the clip card after the editor is gone.
2026-08-21 04:20:18 +02:00
juancarlos.cavero
730f7de949 fix: reject too-short sources at submit and stop alerts blaming recovered downloads
Prod 20-ago, 5 of 12 managed jobs failed and the alert said 'youtube
download' — no download had terminally failed. Three fixes:

- The quality probe now reports source duration, and /api/process rejects
  sources under MIN_SOURCE_SECONDS (default 45, 0 disables) on all three
  ingest paths with a clear message. A 24s YouTube Short cannot yield
  15-60s clips; Gemini returns nothing and the job burns managed minutes
  to die with 'no usable clips' (3 of the 5 failures, one user retrying
  the same cat video).

- _job_error_text drops per-attempt download warnings when a later
  attempt succeeded (HD-direct fails on every job since the server IP
  ban; static proxies recover it), and gained an 'Error:' marker so
  raised exceptions (RuntimeError:, GeminiBlockedError:) reach the alert
  instead of a bare 'Traceback ... exit code 1'. The classifier names
  'no clips found (user video)' as its own content-shaped category.

- (env, no code) DIRECT_FIRST=0 in prod: with the server IP banned the
  direct attempt only added ~10s and the noise behind these alerts.
2026-08-20 22:54:51 +02:00
juancarlos.cavero
e4792fd3b3 feat: hand the Thumbnail Studio video and transcript straight to the clip generator
Issue #68: publishing a video to YouTube from the Studio now offers
'create clips from this video'. /api/process accepts a
thumbnail_session_id, hardlinks the session's source under the job's
name (so /api/source, the clip editor and retention treat it like a
normal upload) and forwards the session's transcript via a new
main.py --transcript flag, so the pipeline skips a second Whisper pass.

Any problem with the forwarded transcript (missing file, no segments,
silent source) falls back to transcribing normally, and empty
transcripts are not forwarded at all. Contract pinned by six endpoint
tests plus a fallback case; verified end to end locally against the
running app (speech video: 'Reusing precomputed transcript (4
segments)' in the job log).
2026-08-20 19:48:13 +02:00
juancarlos.cavero
d0e1f5adfd feat: raise the self-host job retention default to 24h and surface it in the UI
Issue #46 round two: the 1h sweep kept deleting finished projects under
self-hosters who never touched their env. The disk is already bounded by
OUTPUT_MAX_GB / UPLOADS_MAX_GB, so age can afford to be generous. Cloud
keeps the tight default because clips are archived to R2 on completion.

The results panel now tells self-host users how long their clips live
and which env var controls it, and the restorable-session window follows
the new default.
2026-08-20 19:29:55 +02:00
juancarlos.cavero
1cbd22991c fix(docker): keep the YOLO weights in the workdir as before
YOLO_MODEL_PATH stays available for deployments that need it, but the
image no longer sets it, so the default behavior is identical to what
every existing deploy already runs.
2026-08-20 18:55:16 +02:00
juancarlos.cavero
8996ac9c1a fix: make the YOLO weights path configurable and drop a dead import
Adds YOLO_MODEL_PATH (default unchanged) and bakes the weights into
/tmp/Ultralytics in the image so a volume mounted over /app can't shadow
them, plus removes the redundant top-level scenedetect import.

Adapted from #47 by @kayceepeece, minus the CPU-only torch pin which
would conflict with the GPU production build.
2026-08-20 18:51:39 +02:00
psociety
fea6364ffb
docs(readme): fix placeholder clone URL
Squash-merge of #6 by @psociety
2026-08-20 17:48:37 +01:00
juancarlos.cavero
03fb9e7613 test(render-service): pin the composition metadata contract for per-render props 2026-08-20 18:39:43 +02:00
looksg00d
b8816b2db5 fix(remotion): honor per-render duration/fps/dimensions via calculateMetadata
The ShortVideo Composition hardcoded durationInFrames/fps/width/height
from DEFAULT_PROPS. Since there was no calculateMetadata callback,
selectComposition()/renderMedia() in render-service ignored whatever
durationInFrames/fps/width/height was actually passed in inputProps at
render time, always producing a fixed 900-frame (30s) 1080x1920 output
regardless of the real clip length.

Verified: rendered with durationInFrames=300 (10s) before this fix
produced a 30s file (base video frozen on its last frame for the
remaining ~20s). After adding calculateMetadata, output duration
matches the requested frame count exactly.
2026-08-20 18:34:19 +02:00
juancarlos.cavero
d83e0dddbf refactor(reframe): clean up the v1 fallback loop and get_video_resolution
The v1 frame loop has been the rarely-taken fallback since the v2 engine
shipped in July; give it the same shape as the rest of the file while it
sticks around as the REFRAME_ENGINE=v1 rollback:

- get_video_resolution releases its capture in a finally block
- staging files named .v1video/.v1audio next to the final output, cleaned
  with one loop instead of three inline conditionals
- the rawvideo pipe spells out demuxer options (-video_size/-framerate/
  pipe:0) instead of the short aliases, and drops the redundant -vcodec
- encoder/reader names instead of ffmpeg_process/cap; single -c copy mux
  command built by list concatenation
- dead script_start_time assignment removed

Behavior is unchanged: verified end to end with REFRAME_ENGINE=v1 on a 6s
clip (180 frames, 1080x1920 h264+aac, faststart, scrubbed metadata).
2026-08-20 14:41:37 +02:00
juancarlos.cavero
f8bc461c8e test(edl): pin the full-transcript contract with words outside the old window
The existing test's words all sat inside the removed ±45s window, so it
passed with or without the change. Add words starting 160s after the clip
ends: the old windowed code drops them, the new contract ships them. Also
assert the words arrive sorted by start time, which the editor's
follow-along binary search depends on.
2026-08-20 13:36:13 +02:00
mutonby
05f13254e7
Merge pull request #72 from tuliovianna-lab/feat/clip-editor-ux
Clip editor: source monitor, three-point editing, and a timeline that works while edited
2026-08-20 12:33:28 +01:00
juancarlos.cavero
aa0c841b47 feat(landing): mention MCP in the hero description
The hero now pitches the agent audience too: 'also a clipping tool for ai
agents: claude, chatgpt and n8n drive it over mcp', linking to /mcp. Same
sentence added to the crawler-visible fallback copy (landing-fallback.js
must stay in sync with Landing.jsx).
2026-08-20 02:10:08 +02:00
juancarlos.cavero
1be82bc307 fix(legal): drop the 15-day renewal-reminder promise from the Terms
Business decision: the reminder email will not be implemented for now, so
the Terms must not contractually promise it — a broken written promise is
worse than the underlying statutory ambiguity. Renewal terms now state
auto-renewal until cancellation, cancellable anytime from the account.
(The art. 97.1.p TRLGDCU obligation from Ley 10/2025 still exists for
Spanish companies; revisit if enforcement picks up.)
2026-08-20 01:36:46 +02:00
juancarlos.cavero
2900047b78 feat(legal): full legal corpus — Terms, Privacy, Legal Notice in EN+ES
Replaces the single thin Terms & Privacy SPA view with six indexed static
pages (/terms /privacy /legal-notice + /terminos /privacidad /aviso-legal)
built like the SEO pages, in the sitemap and llms.txt but out of the
marketing interlinking ring. The #legal SPA route becomes a hub linking to
them, so the text lives in exactly one place. Footer and the rights-
attestation checkbox now link to the real documents.

Drafted from a clause inventory of OpusClip/Klap/Vizard/Submagic legals
plus a 2026 Spanish/EU compliance review. Notable substance:
- LSSI art. 10 identity (TONVI TECH SL, Málaga) — was missing entirely.
- Rights warranty covers URL-instructed downloads explicitly and declares
  the attestation record (IP+UA+date) as evidence; DSA arts. 11-17
  notice-and-action with repeat-infringer policy.
- Explicit output ownership (clips are the user's; free-tier watermark as
  a written licence condition) and a no-AI-training commitment naming
  Gemini/ElevenLabs/Whisper — clauses none of the competitors have.
- EU withdrawal per CJEU C-234/25: SaaS is a digital service, the 14-day
  right survives with pro-rata payment (not the digital-content forfeit
  the old page used); renewals do not reopen it. 15-day renewal reminder
  duty (Ley 10/2025) stated.
- AI Act art. 50: dubbed clips declared as labelled/marked; users must
  not strip marks.
- Privacy: per-purpose legal bases, named processors, DPF+SCC transfers,
  real retention (7-day free clips, sub+7 days paid — matching
  cloud/config.py), AEPD analytics exemption documented, no cookie
  banner rationale.
- Spanish versions with prevalence clause (art. 60.1 TRLGDCU; AEPD has
  fined foreign-language-only policies). renderPage supports page.lang.
2026-08-19 22:06:11 +02:00
Tulio Vianna
83c45916a2 feat(editor): rebuild the clip editor around a source monitor and a working timeline
Turns the clip editor into a three-point editing surface: mark in/out on
the source, send the range to the clip, and scrub the result — with the
timeline honest about which parts of the edit the last render can already
show.

- Chrome: the source track ignored drags entirely. Without preventDefault
  the gesture became a text selection and then a native drag, which
  swallows every later pointer event and shows the not-allowed cursor.
- The source track's block is draggable (body moves, edges trim) and every
  gesture on it scrubs the source monitor, so a cut is chosen against the
  picture rather than against numbers.
- Three-point editing: mark in / mark out (i / o) off the monitor's
  playhead, then "replace #N" (.) or "insert after #N" (,). Dragging empty
  track marks a range instead of silently appending a segment.
- /edl ships the whole source transcript instead of a ±45s window: a cut
  can only be extended into words the editor was sent. The panel shows all
  of it, follows playback, and seeks the monitor on click.
- Layout: source monitor + its track + transcript | clip preview + its
  track | controls. Each track sits under the video it drives.
- The clip timeline works while edited. A cut that only removes material
  keeps nothing but frames the last render already produced, so it stays
  scrubbable and playable; only material the render never saw is marked
  red, and the playhead — now a solid handle — stops at its edge.

Transcript words render in memoised 50-word slices: repainting a couple of
thousand of them costs ~66ms, and timeupdate fires four times a second.
2026-08-19 15:23:30 -03:00
juancarlos.cavero
dfa31241ca feat(download): flat-rate static ISP proxies before the per-GB proxy
New STATIC_PROXY_URLS env (comma-separated): dedicated ISP IPs with
unlimited traffic, tried after the direct attempt and before the per-GB
paid proxy. With it unset the chain is byte-identical to before.

- plan_download_attempts: pure, unit-tested attempt ordering. Cheapest
  bandwidth first: direct -> statics (rotated per job, uncapped 1080p,
  free bytes) -> paid HD (720p cost cap) -> fallback via paid.
- The 720p cap and the PROXY_BYTES monthly counter now apply ONLY to
  attempts that actually bill per GB — static downloads come in at 1080p
  and don't count toward the cost alert.
- alerts.py watcher generalized to multiple targets: the static pool
  (down = ingest silently moves to per-GB billing, nag with a cost hint)
  and the paid proxy (down = ingest at risk), each with its own
  down/nag/recovered incident state.

Context: the server's IPv4 is hard-banned by YouTube (19-aug-2026), so
DIRECT_FIRST serves nothing and every download was going through
DataImpulse at $1/GB capped to 720p. Verified from prod: all 3 Decodo
dedicated IPs pass the bot-check with cookies+bgutil at 1080p.
2026-08-19 19:28:52 +02:00
juancarlos.cavero
72288bba82 fix(alerts): probe the proxy over plain HTTP
HTTPS through DataImpulse fails in httpx with an SSL record-layer error
even when the proxy is healthy (verified against a working proxy right
after the top-up; yt-dlp's stack tunnels the same proxy fine), so an
HTTPS probe would report a permanent false outage. An exhausted balance
rejects the request at the proxy before forwarding, so plain HTTP still
catches the 407.
2026-08-19 17:11:10 +02:00
juancarlos.cavero
5e84e6486a feat(alerts): proxy balance watcher — nag on Telegram until topped up
The residential proxy ran out of traffic (407 TRAFFIC_EXHAUSTED,
19-aug-2026) and every YouTube-URL job failed with only easy-to-miss
one-shot alerts. Now:

- cloud/alerts.py: a background watcher probes the proxy every 30 min
  (generate_204, a few bytes of paid traffic). On failure it alerts
  immediately, re-alerts every 2 h while the proxy stays down, and sends
  a recovery confirmation when it answers again — so exhaustion is caught
  even before the next user job fails.
- record_job_outcome: a proxy-classified job failure also opens the
  incident, so job-driven detection and the probe share one state.
- app.py: the watcher starts from the lifespan in managed mode.
- tests/test_proxy_watch.py: state machine (first alert, renotify window,
  recovery + reset, job-error trigger).
2026-08-19 17:07:09 +02:00
juancarlos.cavero
f8535b2584 test(hook): styles contract, bitmap-emoji scaling, layer walk-back
- test_hooks.py: the 6-style contract the frontend mirrors (boxed vs
  outline), fixed-bitmap emoji rescaling (_emoji_scale/_measure_width),
  and create_hook_image rendering every style (emoji included) with the
  unknown-style fallback.
- test_hook_layers.py: _strip_burned_hook walk-back (hooked_/legacy hook_,
  missing-file stop), the two-step subtitled->hooked->clean strip /api/hook
  replaces through, and _canonical_clip_file resolving hook chains with
  newest-derivation-wins.
2026-08-19 16:22:38 +02:00
juancarlos.cavero
2b2e287a9b feat(hook): replace semantics — a new hook swaps the burned one, plus remove
The auto-hook was burned into the canonical clip in place, so editing the
hook stacked a second overlay on top of the first. Hooks now follow the
exact derivation pattern captions use:

- main.py: auto_hook_clip writes hooked_<ts>_<clean>.mp4 next to the clean
  canonical instead of mutating it; captions burn on top of the hooked file
  (subtitled_<ts>_hooked_<ts>_<clean>). Watermark moves BEFORE the hook so
  the branding lives in the canonical and survives hook replacement.
- app.py: _strip_burned_hook walks hooked_/legacy hook_ prefixes back like
  _strip_burned_captions; /api/hook strips captions AND the old hook before
  burning, so a new hook always REPLACES the previous one. New remove flag
  strips the hook entirely (captions re-applied, no metering). Burned hook
  recorded/cleared in clip metadata (auto_hook key) and returned as
  burned_hook. _canonical_clip_file resolves hooked_*/hook_* derivations.
- cloud/videos.py: archive the hooked_ intermediate of a captioned hook so
  restored projects keep the walk-back chain editable.
- ResultCard: stripBurns knows hooked_<ts>_ (the Remotion preview now
  composes over the truly clean clip — no more stacked preview), burned
  hook tracked in state, remove handler wired to the modal.
- HookModal: warning now says replace, plus a 'remove hook from clip'
  action when one is burned.
2026-08-19 16:01:53 +02:00
juancarlos.cavero
ac0138269d feat(hook): auto-burn AI hooks on generated clips + working emoji + editor polish
Auto-hook (opt-in per job, dashboard default ON):
- /api/process accepts auto_hook + auto_hook_style; absent means off, so
  API/MCP/webhook callers keep byte-identical output.
- main.py auto_hook_clip burns each clip's viral_hook_text (Gemini already
  produced it, it was only used to pre-fill the modal) into the canonical
  clip in place — after reframe, under watermark and captions — so every
  derived-name convention (subtitled_/recut_ walk-backs, R2 archive,
  restore) keeps working untouched. Fail-open like auto_caption_clip.
- Burned hook recorded as clip.auto_hook in metadata; the hook modal warns
  before stacking a second one.
- MediaInput: 'auto hook titles' toggle + style select in advanced options,
  persisted in localStorage.

Emoji that actually render:
- Gemini prompt now asks for 1-2 emojis in viral_hook_text.
- Dockerfile installs fonts-noto-color-emoji — without it prod silently
  stripped every emoji (no candidate font existed in the image).
- hooks.py supports fixed-bitmap color fonts (NotoColorEmoji only loads at
  its 109px strike; Apple Color Emoji at 160): glyphs render at native size
  and are Lanczos-rescaled to the text size instead of being treated as
  unavailable. macOS system font added for local dev.

Editor polish:
- HookModal persists last style/position/size/entrance (always reset to
  classic before, which read as the picker being broken).
- Remotion preview positions aligned to hooks.py (top 20%, bottom 70%).
- Warning when a bottom hook will overlap burned/preview captions.
- Entrance-animation control greyed out with a note when the clip
  re-renders on the server, where the hook is static.
2026-08-19 14:28:19 +02:00
juancarlos.cavero
8dbc6ce9bd fix(hook): Remotion overlay ignored the style picker, always rendered classic
d94e126 added the 6 hook styles to hooks.py (server FFmpeg path) and to the
HookModal picker, but never to the Remotion composition — which is what
renders both the modal preview and the final clip on the primary in-browser
render path. Picking dark/yellow/red/outline still produced the white
classic card.

- HookOverlay.tsx: HOOK_LOOKS map mirroring hooks.py HOOK_STYLES (box color,
  text color, outline stroke, shadow), applied via config.style.
- types.ts: HookStyle type on HookConfig and hookConfigSchema (default
  "classic" so older payloads keep validating).
2026-08-19 14:12:10 +02:00
mutonby
3e8798f271
Merge pull request #70 from tuliovianna-lab/pr/manual-reframing
feat: manual reframing, per scene
2026-08-19 12:57:03 +01:00
juancarlos.cavero
602f87674b fix(recut): virtual_transcript must keep Whisper's word-boundary spaces
transcript_words() strips each word, so the remapped transcript handed to
the caption generators lost the leading-space convention the block
collector uses as its word-boundary signal — every recut/reframe with
re-applied captions burned the whole line glued together
("...creesycambiatodo"). Latent since the clip-editor merge; surfaced by
the first caption burn over a recut with real words.
2026-08-19 12:22:39 +02:00
juancarlos.cavero
03da5651c0 fix(recut): virtual_transcript must keep Whisper's word-boundary spaces
transcript_words() strips each word, so the remapped transcript handed to
the caption generators lost the leading-space convention the block
collector uses as its word-boundary signal — every recut/reframe with
re-applied captions burned the whole line glued together
("...creesycambiatodo"). Latent since the clip-editor merge; surfaced by
the first caption burn over a recut with real words.
2026-08-19 12:22:39 +02:00
juancarlos.cavero
0d9e04f333 fix(reframe): harden PR #70's manual reframing after review
- Meter the re-render: /api/clip/reframe now reserves/commits/releases
  minutes exactly like a source-path /rerender — it is the same GPU work,
  and it was free and uncapped.
- Re-apply captions by default (reapply_captions param to opt out): every
  default clip ships with burned captions, and the reframe silently
  returned caption-less files.
- Read metadata.json INSIDE the per-job lock (same _reframe_locked shape
  as /rerender): the read-outside/write-inside window let a concurrent
  rerender's recipe get clobbered by a stale write.
- Interplay with whole-clip framing: recipe.framing keeps forcing its
  layout on the scenes the user did not hand-position (apply_crop_overrides
  runs after force_strategy, so per-scene wins where named), and the
  recipe is preserved through the reframe instead of being rebuilt bare.
- /rerender clears stale crop_overrides: scene indices only mean anything
  against the cut they were made for, and the trim render does not apply
  them — leaving them made /scenes reopen showing overrides that would
  land on the wrong shots.
- /scenes: entitlement-gated (it cuts, scene-detects and encodes on every
  open), serialized per job (stable output names tore under concurrent
  opens), 400 on horizontal jobs, real aspect for square jobs, temp_
  prefix on preview/thumbnails (kept out of the self-host S3 backup),
  faststart + timeout on the preview encode.
- Tests for all of it plus the apply_crop_overrides math the PR described
  but did not include (12 new, suite at 502).
2026-08-19 12:09:02 +02:00
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