Repository navigation
fix(cli): propagate the real source frame rate into the tracker - #569
Merged
Borda merged 2 commits intoAug 14, 2026
Merged
Conversation
Borda
previously approved these changes
Aug 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Propagates detected source frame rates into trackers so lost-track buffering reflects actual media timing.
Changes:
- Detects and forwards video FPS in the CLI and demo.
- Reads per-sequence benchmark FPS from
seqinfo.ini. - Adds documentation and regression coverage.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/trackers/cli/track.py |
Seeds trackers with detected video FPS. |
src/trackers/cli/benchmark/mcbyte.py |
Reads per-sequence benchmark FPS. |
demo/app.py |
Passes uploaded-video FPS to trackers. |
docs/guides/track.md |
Documents FPS fallback behavior. |
tests/cli/test_track.py |
Tests CLI FPS propagation and validation. |
tests/cli/test_benchmark_mcbyte.py |
Tests sequence metadata handling and propagation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Borda
approved these changes
Aug 14, 2026
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.
None of the three places that build a tracker from a real source pass it the source's actual frame rate. All of them fall back to the constructor default,
frame_rate=30.0.track_command()insrc/trackers/cli/track.pycalls_init_tracker()beforesource_infoexists in that function's scope.source_infois what holds the real fps, via_classify_source(), so at that point there is nothing to pass yet. It's an ordering problem, not just a missing parameter._get_video_info()indemo/app.pyalready reads the fps withcv2.VideoCapture(...).get(cv2.CAP_PROP_FPS), but only uses it to compute the clip duration and throws it away.track()then buildsByteTrackTracker/SORTTrackerwith noframe_rate=at all.run_sequence()insrc/trackers/cli/benchmark/mcbyte.pypassesDatasetConfig.frame_rate(one default shared by every sequence in a dataset) straight intocreate_tracker(). There is no mention ofseqinfo.inianywhere in the repo before this PR.I checked how far off the shared default actually is against real data. The integration tests already cache real MOTChallenge-format sequences locally, and their
seqinfo.inifiles showframeRate=25for all 45 cachedSportsMOT-valsequences, andframeRate=20for all 25 cachedDanceTrack-valsequences. So this is not a couple of outlier sequences. The default is wrong for every sequence checked, in both datasets this benchmark supports.Changes
src/trackers/cli/track.py: reorderedtrack_command()to classify the source (metadata only, no frame decode) before building the tracker, and threaded that into_init_tracker()through a newdetected_frame_rate: float | None = Noneargument.It only fills
kwargs["frame_rate"]when three things hold: the selected tracker accepts that argument, there is no explicit--tracker.frame_rateoverride already set, and the detected value is finite and> 0. That last check matters, a corrupt container can reportinf/nanthroughcv2.CAP_PROP_FPS, and without the guard that would reach the tracker constructor and crash insideBaseTracker._compute_maximum_frames_without_update'smath.isfinitecheck. An explicit override always wins.For a pure
--detection.mot_filereplay there is no video to read a fps from.detected_frame_ratestaysNoneand every tracker keeps its own default. That's correct, not a gap.demo/app.py:_get_video_info()now also returns thefpsit was already reading. It's guarded the same way, rejecting non-finite values and not just non-positive ones, because this value used to be display-only and is now forwarded live into the tracker constructor.track()forwards it asframe_rate=toByteTrackTrackerandSORTTracker.src/trackers/cli/benchmark/mcbyte.py: added_read_sequence_frame_rate(image_dir, default, *, logger=None, sequence=""). It readsimage_dir.parent / seqinfo.ini(the standard MOTChallenge layout) and parses[Sequence] frameRatewithconfigparser, falling back to the dataset default when the file is missing, unparsable, or the value is not finite/positive.A missing
seqinfo.inistays silent, and that's unremarkable. A present but broken one — unparsable content, or a non-finite/non-positiveframeRate— now logs a warning naming the file, so a dataset shipping bad metadata doesn't silently pass for one with no metadata at all.run_sequence()now uses that per-sequence value instead ofconfig.frame_ratedirectly, and logs once per sequence when the two differ.docs/guides/track.md: updated the--tracker.frame_ratereference row. It used to say the default was just the tracker's own default; now it says a readable source FPS is used first, when the flag is left unset.One sibling I did not touch:
SequenceOptions.frame_rateinsrc/trackers/cli/inspect/mcbyte.py:109has the same shape, a defaulted fps field. But that tool is a manual debugging entry point. The user already suppliesimage_dir,det_file,start_frame,end_frame,det_formatby hand for every run, so there is no automatic source detection there for a real value to get discarded from. Left it out of scope on purpose, not something I missed.A second one I also left alone, for a different reason.
Tuner._build_tracker()insrc/trackers/tune/tuner.pybuilds one tracker per trial withframe_rateon the same hardcoded 30.0, then reuses that single instance (tracker.reset()only) across every sequence inself._sequences.frame_rateis not in any tracker'ssearch_space, so nothing here ever sets it from real data either.images_dir— where aseqinfo.iniwould live — is optional, and only required whenenable_cmc=True.Closing this one the same way needs an actual design decision. Either rebuild the tracker per sequence with its own detected fps, which changes what "one tracker instance per trial" means in
_objective(), or accept one fps for a whole trial even when the sequences mix rates. That's not a call I want to make inside a plumbing PR, so I'm leaving it flagged instead of touching it or staying quiet about it.This PR does not re-run the McByte benchmark or regenerate any of the golden results. That needs SAM/Cutie GPU compute, and it's outside what I wanted to take on here.
Worth flagging clearly though: running
trackers benchmark mcbyteagain after this fix could move the HOTA/MOTA numbers published indocs/evaluations/results.mdfor SportsMOT and DanceTrack. Only the lost-track buffer is affected, the Kalman process noise is not.BaseTracker._compute_maximum_frames_without_updatescaleslost_track_bufferbyframe_rate / 30.0once at tracker construction. So with McByte's defaultlost_track_buffer=30, the missed-frame budget goes from 30 frames (old hardcoded 30fps default) to 25 frames on SportsMOT-val (25fps), and 20 frames on DanceTrack-val (20fps).The Kalman noise band in
motion_models.py::build_Qonly becomes fps-aware when aframe_ratereaches it throughPredictTiming, the timestamped/dynamic-rate path.run_sequence()never passes a timestamp toupdate(), so it stays on the fixed frame-unit fallback regardless of this fix. I have not re-measured the buffer's downstream effect on HOTA/MOTA, I'm just leaving the mechanism and its exact magnitude as a known consequence for whoever runs the benchmark next.Validation
pre-commit run --all-files: all 18 hooks clean (license header, ruff check/format, docformatter, mdformat, codespell, mypy onsrcandtests).run_sequence()'sframe_rate=frame_rateback toframe_rate=config.frame_rate(the pre-fix behaviour) and reran the new tests. Exactly one failed (test_seqinfo_frame_rate_reaches_create_tracker,assert 30.0 == 25.0), the other 9 stayed green — expected, since the "no seqinfo" case is unaffected by the bug. Restored the fix, the full suite is green again.tests/cli/test_track.py::TestInitTrackerDetectedFrameRate(6 tests, detected value reaches the tracker, explicit override wins, non-positive/non-finite/Nonevalues are ignored, every registered tracker currently acceptsframe_rate),tests/cli/test_track.py::TestTrackCommandDetectsSourceFrameRate(2 tests, end to end with a real 24fps video written viacv2.VideoWriterand round-tripped throughcv2.CAP_PROP_FPS, and the no-source case),tests/cli/test_benchmark_mcbyte.py::TestReadSequenceFrameRate(8 tests, parametrised over0,-25,nan,inf, plus 3 covering the new seqinfo-present-but-broken warning),tests/cli/test_benchmark_mcbyte.py::TestRunSequenceUsesRealFrameRate(2 tests,create_trackermonkeypatched to a stub capturing theframe_ratekwarg, the realMcByteTrackerneeds SAM/Cutie which is too heavy for a wiring check)._init_trackeranddemo/app.py::_get_video_infoonly rejected<= 0fps, not non-finite fps. Since this PR is what makes that value reach the tracker constructor live (it used to be display-only), aninf/nanfrom a corrupt container crashed with an unhandledValueErrorinstead of falling back. Added the samemath.isfiniteguardbenchmark/mcbyte.pyalready had._read_sequence_frame_ratefell back identically, and silently, whetherseqinfo.iniwas simply absent or present-but-broken. Added an opt-inlogger/sequencepair sorun_sequencecan warn on the latter case specifically.run_sequencenever passes a timestamp toupdate(), so the tracker stays in fixed-rate mode, only the lost-track buffer scaling is affected.tests/cli/test_track.py -m "not integration"reverified after these fixes: 51 passed.tests/cli/test_benchmark_mcbyte.py's logger-warning behaviour was verified by direct module import (_read_sequence_frame_ratecalled standalone) rather than through pytest, because collecting that test file needsjsonargparse, which isn't installed in the environment available for this review round. That's a declared runtime dependency (pyproject.toml), not something this PR adds or removes, and none ofbenchmark/mcbyte.py's other tests were touched by the review-round changes.