Skip to content

[bugfix] Accept image sequences with the default or configured opencv backend (#620) - #621

Open
goranai wants to merge 1 commit into
Breakthrough:mainfrom
goranai:fix/image-sequence-default-backend
Open

goranai wants to merge 1 commit into
Breakthrough:mainfrom
goranai:fix/image-sequence-default-backend

Conversation

@goranai

@goranai goranai commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Image sequence input (-i frame%03d.png) was rejected unless -b opencv was typed, even though OpenCV is the default backend and even when the config file sets backend = opencv.

CliContext._open_video_stream tested backend != "opencv" with the raw -b value (None when not given). The configured or default backend was read two lines later, after the check had failed. This moves that self.config.get_value("global", "backend", backend) line above the check, so the check sees the backend that will really be used. -b still wins over the config file.

Before:

$ python -m scenedetect -i tests/resources/counter/frame%03d.png -f 30 detect-content list-scenes
Error: Invalid value for -i/--input: The OpenCV backend (`--backend opencv`) must be used to process image sequences.

After: the command runs. -b pyav, -b moviepy, or backend = pyav / backend = moviepy in the config file with an image sequence still give the same usage error.

Behavior changes:

  • Any -i path containing % goes through the same check, so a plain file such as 100% done.mp4 now opens with the default backend instead of being rejected. With -b pyav or -b moviepy it is still rejected.
  • A % path that does not exist now gets the normal "Failed to open input video" error instead of the image sequence error, when the effective backend is opencv.
  • An invalid backend value in the config file behaves as before.

Tests: three new tests in tests/test_cli.py. test_cli_image_sequence_uses_default_backend and test_cli_image_sequence_uses_config_backend fail on main and pass with the change. test_cli_image_sequence_rejects_other_backend passes on both and guards the kept error. tests/test_cli.py without the pyav and moviepy backends installed: 148 passed, 18 failed. The 18 failures need those backends and fail on main too. ruff check and ruff format --check on the changed files are clean, and pyright on scenedetect/_cli/context.py reports 0 errors.

Note: open PR #591 also edits _open_video_stream (it adds a frame_numbering parameter), so whichever lands second needs a one-line context rebase. The two changes do not overlap in intent. I checked that this diff applies on top of #591 with git apply -C1, and the three tests pass there.

Fixes #620

Validated with Claude Opus 5.5.

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.

Image sequences are rejected unless -b opencv is typed, even though opencv is the default backend

1 participant