Skip to content

detect-content / detect-adaptive -k with an invalid kernel size crashes with a traceback; config accepts kernel-size = 1 #604

Closed

Description

@goranai

Description

Passing -k/--kernel-size with a value the detector does not accept (1, an even number, a negative number) makes the CLI exit with a Python traceback instead of a usage error. The same happens with kernel-size = 1 in a config file: the config validator accepts 1, although its own docstring and error message say the value must be greater than 1, and the detector requires an odd integer >= 3. Other options of the same commands (--weights, --downscale) already report a bad value as a usage error.

Command

scenedetect -i tests/resources/testvideo.mp4 detect-content -k 1 time -e 2s
scenedetect -c k1.cfg -i tests/resources/testvideo.mp4 detect-content time -e 2s

where k1.cfg is:

[detect-content]
kernel-size = 1

detect-adaptive -k 1 (and -k 4, -k -3) behave the same.

Output

Traceback (most recent call last):
  ...
  File "...\scenedetect\detectors\content_detector.py", line 138, in __init__
    raise ValueError("kernel_size must be odd integer >= 3")
ValueError: kernel_size must be odd integer >= 3

Environment

PySceneDetect 0.8-dev0 (main @ c0d4870)
OS                     Windows-11-10.0.26200-SP0
Python                 CPython 3.12.16
av                     19.0.2
click                  8.5.1
opencv-python          5.0.0.93
numpy                  2.5.4

Media/Files

tests/resources/testvideo.mp4 from the resources branch.

I have a small fix with tests ready and will open a PR referencing this issue.

AI disclosure: found and reproduced with Claude Code (Claude Opus 5.5), reviewed by me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions