Commit graph

291 commits

Author SHA1 Message Date
juancarlos.cavero
70260108cc feat(free): watermark lockup arriba-izquierda + modal de upgrade + star-ask durante el render
- La marca pasa de texto abajo-centrado a un lockup blanco (símbolo +
  OpenShorts) superpuesto arriba a la izquierda: el borde inferior es lo
  que se recorta al repostear, así que ahí la marca se quitaba gratis.
  PNG pre-renderizado en assets/ para no depender de fuentes del contenedor.
- WatermarkModal: aviso único al descargar en plan free (descargar igual /
  upgrade / no volver a mostrar), al estilo del de OpusClip.
- StarBanner también durante la generación, que es donde el usuario tiene
  minutos muertos esperando.
2026-07-20 18:58:00 +02:00
juancarlos.cavero
f68bf12fee ci: install sqlalchemy so the free-plan metering tests can import cloud.metering 2026-07-20 18:12:33 +02:00
juancarlos.cavero
a42297f120 Merge origin/main: analytics + billing cross-sub guard
Conflicto resuelto en AuthContext (se mantienen el track('Signup') y el
enrutado del plan free). Además, fix de la interacción entre ambos cambios:
AccountPage daba el checkout por activado en cuanto /api/me devolvía un
plan, pero 'free' ahora existe desde el primer instante — se exige un plan
de pago antes de parar el polling, disparar el goal Subscribed y llevar al
usuario a conectar sus redes.
2026-07-20 15:22:52 +02:00
juancarlos.cavero
afcc9de9e2 Merge feat/free-plan: plan free 20 min/mes sin tarjeta, sin trial, galería opt-in 2026-07-20 15:19:38 +02:00
victormanuel.caverogracia
9685346cd6 Add OpenPanel analytics snippet (parallel to Plausible) 2026-07-20 11:28:21 +02:00
juancarlos.cavero
9fd1cacb0c feat(billing): free plan (20 min/mes sin tarjeta) + retirar trial + opt-in galería UGC
- Plan free resuelto en metering (sin fila Stripe): 20 min/mes para cuentas
  Google, período sintético de mes natural con reset automático
- TRIAL_DAYS=0 para nuevos checkouts; trials en curso grandfathered
- Watermark drawtext en clips free (pasada única post-render, sobrevive
  subtítulos/hooks); thumbnails IA solo de pago
- Anti-abuso: 3 jobs/día por cuenta, 5 por IP, rate-limit de probes,
  contador mensual de GB de proxy con alerta Telegram a 100 GB
- Clips free caducan a 7 días (purge_free_expired); purge_expired respeta
  a cancelados que ahora son free
- Galería UGC pública pasa a opt-in (share_to_gallery, antes publicaba
  producto+guion de todos los usuarios sin permiso)
- Emails: clips listos (con star-ask) y sin-minutos (cooldown 24h)
- Frontend: card Free en pricing, copy sin trial (landing/legal/gates),
  StarBanner en resultados y TopUpModal, upsell de watermark
2026-07-20 00:26:21 +02:00
victormanuel.caverogracia
99e113130d analytics: track funnel goals (Signup, CheckoutStarted, Subscribed) via Plausible
Add a small no-op-safe track() helper and emit three custom events so we can
see where users drop off between landing and paid: Signup on auth callback,
CheckoutStarted before the Stripe redirect, Subscribed on plan activation.

Plausible here is Community Edition (no revenue goals), so the plan price rides
along as a plain value_usd prop instead of a revenue field. Self-hosted builds
without the analytics script are unaffected (track() no-ops).
2026-07-19 14:18:11 +02:00
victormanuel.caverogracia
747a1d5f95 fix(billing): don't let a non-current subscription clobber the live row
subscriptions keeps one row per user, keyed on user_id in _upsert. An event
for a *different* sub of the same user (e.g. canceling a dangling past_due
annual while a monthly trial is live) would overwrite the good row. Add a
cross-subscription guard: another sub only takes over the row when the stored
one is no longer live.
2026-07-18 23:42:21 +02:00
juancarlos.cavero
d5f2767d70 Merge fix/ui-model-badge-clip-preview: clip card redesign + social connect gating 2026-07-18 23:38:14 +02:00
victormanuel.caverogracia
9e5aa7431d fix(billing): block new checkout for past_due/unpaid/incomplete subs
Guard only blocked active/trialing, so a user whose first charge failed
(sub in past_due) could create a second subscription. Real case: annual
trial -> end-trial -> card declined -> past_due, then a fresh monthly sub,
leaving two live subs on one customer. Now any non-terminal status blocks.
2026-07-18 23:35:08 +02:00
juancarlos.cavero
8d41112617 feat(ui): gate publishing when no social accounts are linked; guide user to connect flow 2026-07-18 23:24:20 +02:00
juancarlos.cavero
1e40f9aa6e fix(ui): stack icon over label on clip action buttons so they never collide 2026-07-18 23:15:32 +02:00
juancarlos.cavero
1b82315615 fix(ui): keep clip action button labels on one line and square up the post button 2026-07-18 14:49:31 +02:00
juancarlos.cavero
f65a35762e feat(ui): compact one-line description rows with full-text modal on clip cards 2026-07-18 14:45:48 +02:00
juancarlos.cavero
f57cb7a29a fix(ui): let clip cards grow to content (min-h) and cap description area so footer never clips 2026-07-18 14:37:07 +02:00
juancarlos.cavero
d7a1c35154 fix(ui): fixed-height clip cards with true 9:16 video column; stop hover-expanding descriptions 2026-07-18 14:33:37 +02:00
juancarlos.cavero
928b4a3ddc fix(ui): hide model name in HUD badge; show clips at true aspect with resolution chip 2026-07-18 13:56:20 +02:00
juancarlos.cavero
d2febde078 Merge branch 'main' of github.com:mutonby/autoclips 2026-07-18 13:51:30 +02:00
juancarlos.cavero
20f9c94c31 Merge feat/transnetv2-scene-detection: neural scene detection (TransNetV2)
A/B validated on 10 topic-diverse clips + full-pipeline smoke test:
- TransNetV2 replaces ContentDetector (fixed threshold) as primary detector;
  automatic fallback + SCENE_ENGINE=pyscenedetect rollback lever
- removes false cuts on fast motion (gaming/music), finds real cuts the
  threshold missed (same-palette shots), handles gradual transitions
- min-scene merge 0.4s + robustified TRACK/GENERAL strategy (5 samples,
  near-black skip, hysteresis)
2026-07-18 13:51:00 +02:00
juancarlos.cavero
e8759d158f fix: retry whisper on CPU when CUDA fails (OOM on shared GPU killed jobs) 2026-07-18 13:43:43 +02:00
juancarlos.cavero
40a6427c71 fix: retry whisper on CPU when CUDA fails (OOM on shared GPU killed jobs) 2026-07-18 13:43:00 +02:00
juancarlos.cavero
ef43c282c7 fix(reframe): lower SCENE_MIN_SEC default 1.0s -> 0.4s
A/B audit on 10 topic-diverse clips showed the 1s merge deleted real
sub-second shots in fast-cut content (10/13 lost real cuts in gaming,
9/10 in anime, 5/8 in music videos were present in the raw TransNetV2
output and removed by the merge). 0.4s still kills flash/single-frame
scenes and snap bursts without eating real fast cuts.
2026-07-18 04:39:15 +02:00
juancarlos.cavero
36cf6d33b1 fix(reframe): robustify per-scene TRACK/GENERAL strategy
- Sample 5 evenly-spread frames clamped inside the scene (old start+5/end-5
  fell outside scenes shorter than ~10 frames)
- Skip near-black frames so fades stop dragging single-person scenes to GENERAL
- Hysteresis: a sub-2s scene flanked by agreeing neighbors adopts their
  strategy — each TRACK<->GENERAL flip is a full layout change on screen
2026-07-18 03:51:50 +02:00
juancarlos.cavero
101a467c34 feat(reframe): TransNetV2 neural scene detection with PySceneDetect fallback
New scene_detection module: TransNetV2 (small 3D-CNN, runs on 48x27 frames)
as the primary shot-boundary detector — far more accurate than the fixed
ContentDetector threshold on fast motion, flashes and gradual transitions.
Adds a min-scene-length merge (SCENE_MIN_SEC, default 1s) to stop camera-snap
bursts. Legacy PySceneDetect path is preserved untouched as automatic
fallback and selectable via SCENE_ENGINE=pyscenedetect.
2026-07-18 03:49:01 +02:00
juancarlos.cavero
927ee09ffc feat(projects): reopen archived projects from history for further editing
- New projects table (job_id, metadata_r2_key, state JSONB) — created via create_all
- archive_job also uploads the metadata JSON (transcript) and upserts the
  Project row + user_videos (no more duplicate rows on re-archive)
- archive_clip_edit re-archives a clip after each server-side edit, keeping
  only the pristine original + current version per clip in R2
- fix /api/edit: persist new video_url in job result + metadata.json (the
  other edit endpoints already did)
- POST /api/projects/{job_id}/restore re-hydrates R2 files into output/{job_id}
  (per-job lock, temp-dir download, .owner sidecar, idempotent fast path)
- GET /api/projects + PUT /api/projects/{job_id}/state (debounced Remotion
  layer sync from the frontend)
- History tab groups clips by project with a reopen button; App restores
  jobId/results/project state; ResultCard seeds serverVideoFile/activeLayers
  from the restored state and reports changes upward
2026-07-18 03:42:17 +02:00
juancarlos.cavero
abf43c60b7 Merge reframe-speedup: 4.2x faster reframing (quick wins + v2 ffmpeg-native engine + parallel clips) 2026-07-18 03:19:02 +02:00
juancarlos.cavero
dd867f098a feat(reframe): parallel clip processing (CLIP_WORKERS, default 3) with detector lock; fix v2 Fraction fps 2026-07-18 03:08:34 +02:00
juancarlos.cavero
7ff41735a6 feat(reframe): v2 engine — downscaled analysis pass + native ffmpeg render (sendcmd dynamic crop, per-scene segments, stream-copy concat), auto-fallback to v1 2026-07-18 03:05:36 +02:00
juancarlos.cavero
aeca9dbf98 perf(cut): stream-copy remux in passthrough finalize — the cut is already freshly encoded, re-encoding only added time and generation loss 2026-07-18 02:57:39 +02:00
juancarlos.cavero
402e585af7 perf(reframe): downscaled detection (640px), stride 2->4, throttled YOLO fallback, linear resize, quarter-res background blur, per-stage timing 2026-07-18 02:48:53 +02:00
juancarlos.cavero
b9aeaac692 security: never print cookie-file content; scrub credential URLs from worker-appended error log lines 2026-07-18 02:38:16 +02:00
juancarlos.cavero
6430819dac fix(progress): force the 100% transcription line (VAD trims trailing silence) 2026-07-18 02:27:25 +02:00
juancarlos.cavero
8160fc6465 feat(cloud): user-friendly job logs + transcription progress; hide auto profile id in header
- log_view.py: whitelist-based cloud log view — transcription percentage,
  clip counters, errors; no file paths, model names or pipeline internals.
  Self-host (BILLING off) and DEBUG_LOGS keep the full raw output.
- transcribe_backends: emit '🎙️ Transcribing… NN% (Xs)' at 25% steps from
  both parakeet and whisper paths.
- dashboard: profile selector shows connected networks instead of the
  auto-generated os_<hash> id.
2026-07-18 02:20:31 +02:00
juancarlos.cavero
913c461b9b fix(nvenc): force yuv420p output — RGB pipe input made nvenc emit GBR-colorspace H.264 that web players render with swapped colors 2026-07-18 02:00:18 +02:00
juancarlos.cavero
79e1ef707d Merge gpu-migration: Parakeet ASR + NVENC + GPU Dockerfile 2026-07-18 01:48:53 +02:00
juancarlos.cavero
7bdaf8208b docker: pre-create /app/.cache/huggingface so the HF cache volume mounts appuser-writable 2026-07-18 01:40:46 +02:00
juancarlos.cavero
719d444139 feat: GPU pipeline — Parakeet ASR backend with whisper fallback + NVENC encoder helper
- transcribe_backends.py: parakeet-tdt-0.6b-v3 (onnx-asr, VAD+timestamps) as
  selectable backend (TRANSCRIBE_BACKEND), token->word reconstruction keeping
  the leading-space convention, absolute timestamps, native floats, language
  detection via py3langid, and automatic whisper fallback (errors, empty
  output, or language outside parakeet's 25).
- whisper singleton + ASR GPU semaphore (model stays resident; GPU decodes
  serialized; CPU path behavior unchanged).
- ffmpeg_utils.py: central encoder args (FFMPEG_ENCODER=x264|nvenc|auto with
  cached probe + fallback); migrated the 9 hardcoded libx264 call sites.
- saasshorts now honors WHISPER_* config instead of hardcoded base/cpu/int8.
- Dockerfile: ARG GPU=1 installs CUDA user-space libs (cuBLAS/cuDNN9) +
  onnx-asr/onnxruntime-gpu; LD_LIBRARY_PATH + NVIDIA_DRIVER_CAPABILITIES.
- Validated on prod GPU (RTX 4000 Ada, driver 580): 94s clip transcribed in
  6.5s, word timestamps within ~0.1s of whisper, fallback path exercised.
2026-07-18 01:38:11 +02:00
juancarlos.cavero
5bcdda38f6 cloud: also hide AI model/provider, cost and pipeline internals from client logs
Extend the sensitive-log filter so cloud users don't see which model powers
the app (gemini/flash), token/cost lines, or the 2-pass window/shortlist
internals — just clean transcription + clip progress. DEBUG_LOGS still shows
everything locally.
2026-07-18 00:36:14 +02:00
juancarlos.cavero
29fed21495 cloud: hide ingest plumbing (proxy/download/cookies) from client logs
Cloud users don't need the YouTube downloader internals, proxy usage or
cookie handling in the System Logs panel — just analysis + rendering
progress. Drop lines matching those keywords from the client view even when
emoji-prefixed. DEBUG_LOGS (local dev) still shows everything.
2026-07-18 00:34:24 +02:00
juancarlos.cavero
afe320ca04 ui: aspect-ratio glyph + use hint under each output-format option
Each format button now shows a little rectangle in its real proportion
(tall 9:16, square 1:1, wide 16:9) plus what it's for, so the choice reads
at a glance instead of needing a hover tooltip.
2026-07-17 22:41:55 +02:00
juancarlos.cavero
b3e44643cc feat: 2-pass Gemini clip pipeline (score windows -> detail shortlist)
Replaces the single whole-transcript call with windowed scoring + focused
detailing (from PR #50), for better clip coverage on long videos:

- clip_selection.py: build_transcript_windows (sentence-aligned overlapping
  windows), snap_clip_to_words (cuts land in pauses, not mid-word), model
  price table.
- gemini_worker.py: score/detail prompts + Pydantic response schemas + robust
  JSON parsing and multi-stage cost accounting (incl. thinking tokens).
- main.py get_viral_clips: pass 1 scores windows in batches and shortlists the
  top (scaled by duration); pass 2 details the shortlist; every clip is snapped
  to word boundaries. Cost is summed across both passes. Falls back to
  whole-video conversion (caller) if it yields nothing.
- 13 clip_selection unit tests (63 total).
2026-07-17 22:32:04 +02:00
juancarlos.cavero
861134f8fe feat: quality gate, output-format selection, whisper small (PR #50)
- Quality gate: quality_probe.py probes the offered YouTube resolution before
  starting; /api/process returns needs_confirmation below QUALITY_GATE_MIN_HEIGHT
  (720p) and the UI shows a 'process anyway' modal that resends with
  force_low_quality. Fail-open on any probe error. URL sources only.
- Output format: MediaInput picks 9:16 / 1:1 / 16:9; threaded through
  /api/process -> main.py --format. render_clip() routes vertical/square to the
  reframe (aspect_ratio param) and horizontal to a passthrough (keep landscape).
- Whisper: main pipeline defaults to 'small' (better non-English) with
  vad_filter + no cross-segment conditioning; env-overridable.
2026-07-17 22:21:46 +02:00
juancarlos.cavero
9693543f2d fix(ui): fall back to backend source preview on recovery when media is missing
The save-side fix only helps sessions saved after it; already-recovered
sessions (and any older ones) had processingMedia=null and stayed null. On
recovery, when no media is stored, point the preview at /api/source/{jobId}
so existing upload sessions get their original-video preview back too.
2026-07-17 22:01:10 +02:00
juancarlos.cavero
97378ab102 feat: restore original-video preview for uploads after reload
The live-analysis preview above the logs used a blob URL for uploaded
sources, which dies on page reload — so a recovered upload session showed an
empty preview (YouTube-URL jobs were fine, their URL persists).

- GET /api/source/{job_id} streams the job's original upload (FileResponse,
  unauthenticated like /videos, UUID job_id is the capability).
- ProcessingAnimation: new 'server' media type -> <video src> from the backend.
- Session save persists uploads as { type:'server', payload:/api/source/id }
  instead of null, so the recovered preview plays the real source.
2026-07-17 21:57:37 +02:00
juancarlos.cavero
ff38a9d7ee fix(cloud): compare job owner as string so recovered jobs pass the guard
User.id is a uuid.UUID; live jobs store that object, but jobs recovered from
the .owner sidecar store its string form. 'UUID(x) != str(x)' is always True,
so after a restart the legitimate owner got 404 on /status, /transcript,
/hook etc. for their own recovered jobs. Compare str(user.id) != str(owner).
2026-07-17 21:46:23 +02:00
juancarlos.cavero
be3dc665a3 feat(logs): DEBUG_LOGS env to force full pipeline logs under billing
83b0649 hides raw yt-dlp/ffmpeg/debug spew from paid users. In local dev you
run with BILLING_ENABLED to test paid features but still want the debug logs,
so DEBUG_LOGS=true bypasses the filter regardless of billing.
2026-07-17 21:36:21 +02:00
juancarlos.cavero
880efb4d12 fix(gemini): force JSON output + rescue parse for clip detection
gemini-3.1-flash-lite intermittently emitted JSON the manual fence-strip +
json.loads couldn't parse ('Expecting value: line 16 ...'), so clip
detection failed and fell back to whole-video conversion -> 'No metadata
file generated'. Request response_mime_type=application/json so the API
guarantees a JSON body, and on a parse miss rescue the outermost {...}
object before giving up.
2026-07-17 21:26:04 +02:00
juancarlos.cavero
80a3e2fda7 fix(ui): pristine preview base + sync cards after bulk subtitles
Two bugs, one root cause: the Remotion preview base was derived from
clip.video_url, which mutates to subtitled_/hook_ files after server burns.

- originalVideoUrl now strips subtitled_<ts>_/hook_ prefixes back to the
  pristine clip, so the preview composites new subtitles over the clean clip
  instead of stacking them on an already-subtitled file (the 'subtitles on
  top for a few seconds' double-render when opening another clip's modal).
- currentVideoUrl inits to the actual current file (not pristine), and a new
  effect adopts clip.video_url when an external refresh (bulk apply from
  another card) changes it — so every card shows its freshly subtitled video
  instead of a stale/blank one.
2026-07-17 21:26:04 +02:00
juancarlos.cavero
7162667bbf fix(ui): keep subtitle preview playable for karaoke presets
Selecting a karaoke preset swapped the playable RemotionPreview for a static
CSS mock, so the preview video couldn't be played/scrubbed. Instead, teach
the Remotion Subtitles component to render dim (baseOpacity, opaque scaled
color like the backend) and uppercase, and pass those from the modal — so
the preview stays a live, playable Player that also reflects the karaoke
look. Drops the static mock.
2026-07-17 21:26:04 +02:00
juancarlos.cavero
f683dc66df refactor(ui): move 'apply to all' into the subtitle modal itself
Instead of a separate header button + bulk modal, the per-clip subtitle
editor now has a second action: 'apply this style to all N clips'. Same
bulk loop, but you pick and preview the look on the clip you opened, then
one click applies it everywhere (progress shown inline). Header keeps only
'download all' + 'schedule week'.
2026-07-17 21:26:04 +02:00