Skip to content

[bugfix] Check crop bounds as inclusive in detect_scenes (#623) - #624

Open
goranai wants to merge 1 commit into
Breakthrough:mainfrom
goranai:fix/crop-boundary-warning
Open

goranai wants to merge 1 commit into
Breakthrough:mainfrom
goranai:fix/crop-boundary-warning

Conversation

@goranai

@goranai goranai commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #623.

SceneManager.detect_scenes read the internal _crop, which is stored one past the end, and checked it as if the bounds were inclusive. A crop that ends on the last column or row, such as --crop 0 0 319 239 on a 320x240 video, logged "crop ends outside of video boundary" even though it is inside the frame.

The fix reads the public inclusive crop value instead. It clamps to frame_width - 1 and frame_height - 1.

Behavior changes:

  • A crop that ends on the last column or row no longer logs the false warning. A crop one pixel past the right or bottom edge still logs it.
  • The effective frame size used for the auto downscale factor is now exact. Before, it was 1 pixel larger in each direction for every crop. For a full frame crop it was width + 1.

Tests: added test_crop_boundary_warning (5 cases, 2 fail on main). pytest tests/test_scene_manager.py gives 15 passed and pytest tests/test_cli.py -k crop gives 2 passed (resources branch fetched). A fuzz of 880 random crops on five frame sizes, including 1x1 and 2x2, compared the error, the warning and the effective size with an inclusive-bounds oracle. Main had 513 mismatches and the fix has 0.

Validated with Claude Opus 5.5.

@goranai
goranai force-pushed the fix/crop-boundary-warning branch from 551646c to 7cf960c Compare November 25, 2026 03:11

This branch has not been deployed

No deployments
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.

Crop ends on the last pixel logs a false boundary warning

1 participant