Repository navigation
Keep cuts exactly min_scene_len frames apart at 29.97 and 59.94 fps - #578
Merged
Breakthrough merged 3 commits intoOct 12, 2026
Merged
Conversation
Breakthrough
force-pushed
the
fix/577-ntsc-min-scene-len
branch
from
October 10, 2026 01:30
49746d2 to
b3770ce
Compare
Breakthrough
requested changes
Oct 10, 2026
Owner
There was a problem hiding this comment.
Thanks for the fix. A few small things need to be addressed before we can land this:
_filter_secsis still computed fromlength / float(frame_rate)in both filter methods, even when it is never used for the comparison when_filter_length > 0. Let's just skip it in this case.- Please add a
[bugfix]entry under the 0.7.2 section at the bottom ofwebsite/pages/changelog.mdreferencing
#577. - I'd prefer the new tests live in
test_detectors.py, or next to the existingFlashFiltertests in
test_timecode.py) rather than a new file.
As you noted, the PyAV 19 failures are unrelated - those should be fixed on main now.
Thanks for the PR!
Skip the unused seconds conversion when min_scene_len is given in frames, move the FlashFilter NTSC tests into test_timecode.py, and add a changelog entry.
Contributor
Author
|
Thanks for the review. All three points are done in 4de3571. The seconds conversion is skipped when the length is in frames, the changelog has a |
…ene-len # Conflicts: # website/pages/changelog.md
Contributor
Author
|
Thanks for merging #578, @Breakthrough, and for the careful review that got it there. FlashFilter now compares frame counts when min_scene_len is set in frames, so a cut exactly 17 frames after the last one survives at 29.97 fps.
You can see what else I work on at https://github.com/theluckystrike. If a small one-time sponsorship through https://github.com/sponsors/theluckystrike ever felt right, it'd tell me the time on this fix was appreciated, and I'd gladly keep sending fixes to PySceneDetect. Totally fine if not.
Thank you,
Michael Lip
Founder of https://zovo.one, 108 Chrome extensions with 150,000+ users
Also building https://makeroll.com and https://ml0x.com, open-source guardrails for Claude Code agents
Open source has to win, and small fixes like this one are my part of it
|
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.
Fixes #577
ContentDetector dropped a cut that sat exactly min_scene_len frames after the previous one on 29.97 and 59.94 fps video. Since 0.7 FlashFilter works in time units, so an integer frame length is turned into seconds with length divided by float(frame_rate). For NTSC rates that float isn't exact and the threshold lands a hair above the true gap, so an exact N frame gap fails the check and the cut is lost.
When the length is given in frames, FlashFilter now compares frame counts directly, through the same integer path of FrameTimecode that the other detectors already use. Lengths given in seconds behave exactly as before.
This also covers the smaller OpenCV form from the issue. There, positions are rounded to whole microseconds, so a gap can come out 1 microsecond short of N divided by fps. Comparing frame counts doesn't care about that rounding.
The new tests feed FlashFilter positions the way PyAV reports them (exact PTS) and the way OpenCV reports them (rounded microseconds), at 30000/1001 and 60000/1001, in merge and suppress mode, with no video file. One case is min_scene_len=17 at 29.97 from the issue. 8 of the 10 fail without the change and all pass with it, and tests/test_detectors.py passes too. ruff check and ruff format are clean on both files.
The PyAV backend tests fail on my machine with PyAV 19, from an AVRational conversion in common.py. They fail the same way without this change.
Michael