fix: harden macOS backends and download limits - #15
Open
felores wants to merge 2 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
ffmpegscene 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 skippedbefore the resolution selector change; its focused regression suite is also green)code+message+ actionablefix)core/does not importsurfaces/pathlib, spaces-in-paths tolerated)docs/DECISIONS.mdValidation: 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.