Spaces:
Running
Running
Commit History
-
fix: lifecycle + resource-leak hardening from the audit
ClaudeRemaining confirmed findings, all lower severity: app/jobs.py — job TTL evicted live editors (finding 15): The 10-minute TTL measured from finished_at and was never refreshed by access, so a review session longer than 10 min got its job purged and the editor's lazy /alts, /ocr, /audio fetches and /result re-fetch started 404ing mid-edit. Track last_access_at (bumped on every get()) and purge on idle time = max(finished_at, last_access_at) instead. app/main.py — thread-start leak (finding 19): If the OS refused threading.Thread(...).start() after registry.create(), the job sat in the registry as "running" forever (finished_at stays None → TTL purge never reclaims it), permanently consuming a concurrency slot. Pop the job on a failed start before propagating. app/main.py — upload cap enforced too late (finding 6): The per-field streaming check in _save_upload runs only after Starlette has already spooled the full multipart body to disk. Add an early Content-Len…fbb54cc -
scenes: deterministic frame extraction to stabilise scene detection
ClaudeUsers reported the "Preview scenes" step returning a different set of scenes on every run of the same video. Root cause: representative-frame extraction used cap.set(CAP_PROP_POS_MSEC, …), OpenCV's approximate millisecond seek. That seek lands on the nearest keyframe and decodes forward, and FFmpeg's multithreaded decoder can return a slightly different frame for the same timestamp across runs. The jitter didn't just change thumbnails — it changed the scene COUNT. _merge_duplicate_adjacent compares each scene's extracted frame against its neighbour with a fixed mean-abs-diff threshold (5.0); when a seek returned a marginally different frame, the MAE crossed the threshold and flipped a merge decision, so scenes that collapsed one run stayed split the next. Fix: add _read_frame_at(cap, time_seconds, fps) which converts the timestamp to an integer frame index and seeks via CAP_PROP_POS_FRAMES — a specific decode target that maps far more reproducibly than a millisecond value. Both extra…e059eb2
-
Default to latest-in-time frame as the primary slide candidate
ClaudeAmong the 3 brightness-rank survivors from the second half of each scene, promote the latest-in-time as the primary instead of the brightest. Reviewers almost always want the fully-populated final state of progressive-reveal slides; the brightest sample is often a mid-scene animation flash. The peak still ships as an alternate so the reviewer can switch back if they prefer it.b3c6e2c
-
Three fixes: stale ends, /jobs cleanup window, audio toggle
Claude1. _enforce_min_gap and _cap_max_frames previously only renumbered the kept frames. Each kept frame retained its ORIGINAL end_seconds even though transcript-alignment uses the next kept frame's start as the narration boundary. So a guide could display 'Segment 1: 0:00-0:05' while its narration body actually covered 0:00 through 0:30 (when the next kept scene started). New _absorb_dropped_intervals helper extends each kept frame's end_seconds to the next kept frame's start (or to the original tail for the last). Both helpers call it after renumbering. New test pins the behavior. 2. /jobs widens the cleanup window: previously the try/except only wrapped file-save and max_frames parsing; PipelineInputs(), registry.create(), and Thread.start() ran outside it. If anything in those last three failed (dataclass validation, OS thread limits, etc.) the workdir would leak. Now everything pre-handoff is inside a try/finally with a handed_off flag; rmtree on…e7c2416 -
Sync deps, format validation, /jobs workdir cleanup, timing tests
Claude1. pyproject.toml gains 'anthropic>=0.49' so 'pip install .' brings in the same dependency that requirements.txt declares. Previously fresh installs through package metadata silently lost the LLM feature even when the API key was set. 2. /jobs now wraps the file-save + form-parse phase in try/except so if anything fails between mkdtemp and worker handoff (disk full, bad max_frames value, copyfileobj raising), the workdir is shutil.rmtree'd before the 400 propagates. Mirrors the existing try/finally pattern in /process. Test guard added. 3. Both /jobs and /process now reject unknown 'format' values with a 400 instead of treating anything-not-review-or-single as zip. The CLI already validated this; the web layer now matches. Test guard added. 4. Five new test_scenes.py invariant tests pin the timing properties that align_segments depends on after frames are dropped: * indices contiguous from 0 * start_seconds strictly increasing * end >=…06c75aa -
Phase D: --min-gap, --max-frames, --skip-ocr flag parity
Claudedetect_and_extract now applies, after dedup: an optional min_gap_seconds filter (drops frames closer than N seconds to the previous kept one) and an optional max_frames cap (uniform-stride downsample preserving first + last). Both unlink the dropped frame files so the output folder stays clean. run_pipeline gains skip_ocr (sets ocr_text to "" on every segment) and the new scene-tuning fields. These are exposed as CLI flags (--min-gap, --max-frames, --skip-ocr) on both `vgm build` and `vgm export-metadata`, and as form fields on POST /process so the web UI can use them too. Verified: 37 pytest tests pass (4 new — min-gap drops close frames, max-frames downsamples uniformly preserving first+last, max-frames is a no-op under the limit, CLI build with --skip-ocr --max-frames 2 emits at most 2 segments with empty ocr_text). https://claude.ai/code/session_01G3XpEehfr9DnX9L7BahQ4Lfe75e0e -
Merge near-identical adjacent scenes after detection
ClaudePySceneDetect splits visually-stable openings (fade-ins, codec quirks) into separate scenes, producing redundant adjacent segments with the same slide and OCR. Add a downsampled-grayscale MAE comparison after frame extraction that collapses these duplicates. https://claude.ai/code/session_01G3XpEehfr9DnX9L7BahQ4Lfe8b9d3