Commit graph

5 commits

Author SHA1 Message Date
83ad1feaba refactor: move backend into the clipwright package
All checks were successful
CI / backend-tests (pull_request) Successful in 30s
CI / frontend-build (pull_request) Successful in 29s
Restructure the 37 root-level Python modules into a proper package:
  clipwright/{core,api,pipeline,layouts,media,integrations,tools}

- Rewrite every local import (module-level and deferred) to absolute
  clipwright.<group>.<mod> form; no legacy root shims or re-exports.
- Add clipwright/core/paths.py and route fonts/assets/cookies through it.
- Entry points: uvicorn clipwright.api.app:app; jobs run as
  python -m clipwright.pipeline.main; probe as -m ...quality_probe.
- child_env() appends REPO_ROOT to PYTHONPATH so the -m workers work.
- transcribe_backends: sys.modules key now clipwright.media.scene_detection.
- Tooling: root pyproject.toml (pytest pythonpath=[.], ruff), shared
  requirements-test.txt, CI installs it, Docker PYTHONPATH=/app.
- Tests: all imports/fakes/source-scans repointed; new tests/test_package_layout.py
  enforces no root modules, docstring-only __init__, and no legacy imports.
- Docs/comments updated for the new layout.

Backend: 744 passed, 19 skipped. Frontend lint+build green.
2026-10-04 20:40:38 +01:00
victormanuel.caverogracia
90b10c1902 perf(render): burn the watermark in the reframe encode; read AV1 sources
- The free-plan watermark (~97% of jobs) rode a pass of its own: decode
  the finished clip, overlay, encode it all again. It now goes into each
  reframe segment's own encode (reframe_v2.render(watermark=True), same
  geometry via main.watermark_filter). One NVENC encode less per clip; the
  v1 fallback and horizontal clips still use apply_watermark. The editor's
  paths (recut.py) are untouched.
- layout_picker.sample_frames falls back to the ffmpeg CLI when OpenCV
  reads no frame: OpenCV's bundled FFmpeg has no AV1 software decoder, so
  AV1 YouTube sources always got the default layout. H.264 sources return
  byte-identical frames (same JPEG MD5).

Bench on balrog, 3 videos, old and new run side by side: job CPU -27 to
-43%, wall -6 to -12%; clips SSIM 0.990-0.999 vs before (one generation
fewer), audio identical, watermark position checked by eye.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 19:47:34 +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
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