Skip to content

fix: harden macOS backends and download limits - #15

Open
felores wants to merge 2 commits into
oxbshw:mainfrom
felores:fix/macos-avfoundation-conflict
Open

fix: harden macOS backends and download limits#15
felores wants to merge 2 commits into
oxbshw:mainfrom
felores:fix/macos-avfoundation-conflict

Conversation

@felores

@felores felores commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What

This fixes two observed production problems.

On macOS, importing PySceneDetect eagerly loads OpenCV and PyAV. Their bundled AVFoundation libraries duplicate Objective-C class names, causing warnings and risking capture instability. macOS scene detection now uses the already-required ffmpeg scene score, and local Faster Whisper runs in a clean child interpreter so PyAV does not share the OCR process. Other platforms retain PySceneDetect.

The yt-dlp selector now has a hard 1080p ceiling. Its previous final fallback was uncapped and could select 4K when a capped combined stream was unavailable. The new fallback remains capped and fails safely if a source offers no video at or below 1080p.

Checklist

  • uv run pytest -q -m "not network" is green locally (704 passed, 5 skipped before the resolution selector change; its focused regression suite is also green)
  • New behavior has regression tests
  • Errors raised are structured (code + message + actionable fix)
  • core/ does not import surfaces/
  • Windows-safe paths (pathlib, spaces-in-paths tolerated)
  • Privacy invariants untouched (video never leaves the machine; cloud STT stays opt-in)
  • Non-obvious decisions logged in docs/DECISIONS.md

Validation: the global editable tool completed OCR plus local Whisper without the duplicate AVFoundation warning. The yt-dlp selector test verifies it never emits a bare best-quality fallback.

@felores
felores requested a review from oxbshw as a code owner August 14, 2026 17:46
@felores felores changed the title fix: isolate macOS AVFoundation backends fix: harden macOS backends and download limits Aug 14, 2026
oxbshw added a commit that referenced this pull request Aug 21, 2026
…solute


Ports the two ideas in #15 — an ffmpeg-only scene detector that avoids the
PyAV/AVFoundation conflict, and a real ceiling on download size — with the
parts that would have hurt corrected.

The format selector's old tail was `/bv+ba/b`, with no height predicate at
all, so the fallback rung could pick 4K precisely when the preferred rung had
failed. #15 capped it but made the last rung `bv*[height<=N]`, which is
video-only: the download succeeds, the file has no audio track, and the
failure surfaces much later as a transcript that is mysteriously empty. Every
rung now carries both the cap and an audio stream, and the last resort is a
combined format. The default stays 720p — #15 raised it to 1080 — with 1080 as
a hard ceiling a user may opt up to via WATCHSKILL_MAX_VIDEO_HEIGHT.

The scene detector's correction is the timestamp. `-ss` before `-i` seeks the
input, which restarts the presentation clock at zero, so a cut two seconds
into a window beginning at 10s is reported as pts_time:2. Treating that as
absolute would put every scene in a focused watch near the start of the video,
and every citation with it. The offset is added back explicitly, and a fixture
with a known cut at 12s inside a 10–20s window is what holds it.

The static-shot contract is preserved: no cuts means an empty list, so callers
still fall back to uniform sampling. Returning one whole-window span instead
would look like a detected scene and silently disable that fallback.

Also added, because a subprocess in the watch path needs them: a timeout with
its own error code, bounded stderr (showinfo prints a line per selected frame),
and structured errors carrying a fix.

Tests run wherever ffmpeg does. They do not emulate macOS, and nothing here
licenses a macOS machine-tested claim — that path remains unverified on this
machine.

Ported from #15.

Co-Authored-By: Felo Restrepo <felores@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant