Skip to content

[bugfix] Divide detect-threshold fade-bias by 100 (#625) - #626

Merged
Breakthrough merged 3 commits into
Breakthrough:mainfrom
goranai:fix/threshold-fade-bias-percent
Nov 28, 2026
Merged

Breakthrough merged 3 commits into
Breakthrough:mainfrom
goranai:fix/threshold-fade-bias-percent

Conversation

@goranai

@goranai goranai commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #625.

--fade-bias and the fade-bias config value are a percent from -100 to 100 (see the option help and docs/cli.rst), but ThresholdDetector takes -1.0 to 1.0. Before 9f1525e the CLI converted with fade_bias /= 100.0. That step was lost, so a negative bias raised ValueError: Timecode frame number must be positive and greater than zero. and a positive bias put the cut far past the end of the video (-f 50 gave frame 576 in a 100 frame video).

The change divides the resolved value by 100.0 in CliContext.get_detect_threshold_params, which covers the option and the config file. The default of 0 stays 0.0.

Behavior change: --fade-bias/config values other than 0 now mean what the docs say. Nobody could get a sensible result from non-zero values before, since negative ones crashed.

Tests:

  • New test_cli_detect_threshold_fade_bias_is_a_percent (5 values, builds a small fade video). It fails on main for -100, -50, 50 and 100 and passes with the fix.
  • pytest tests/test_cli.py tests/test_threshold_detector.py tests/test_detectors.py: 254 passed, 1 skipped. A second Windows run without PyAV and moviepy gave 233 passed, 4 skipped and 18 failed, the same 18 tests that fail on main there (PyAV, moviepy and stdin tests).
  • Full pytest tests on main before the change: 743 passed, 1 failed, 2 skipped. The failure is test_write_scene_list_ffmetadata_ffmpeg_roundtrip, which needs ffmpeg on PATH.
  • Sweep of 27 bias values through the CLI against an exact Fraction oracle: main wrong on 26, fix wrong on 0.
  • ruff check and ruff format --check clean on both files.

Validated with Claude Opus 5.5.

@Breakthrough Breakthrough left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to address failing static checks.

@goranai

goranai commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Fixed in b6fb6b4. Pyright flagged cv2.VideoWriter_fourcc in the new test, so it now uses cv2.VideoWriter.fourcc like test_threshold_detector.py. ruff check, ruff format --check and pyright pass on the changed file locally.

Comment thread scenedetect/_cli/context.py Resolved
@Breakthrough Breakthrough added this to the 0.7.4 milestone Nov 28, 2026
@Breakthrough
Breakthrough merged commit f142e0d into Breakthrough:main Nov 28, 2026
23 checks passed
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.

detect-threshold --fade-bias is used as a fraction, so -f -50 crashes and -f 50 puts the cut outside the video

2 participants