Add --start and per-file trim/start flags for narrowing the search to a specific time window - #68
Open
tandav wants to merge 3 commits into
Open
Add --start and per-file trim/start flags for narrowing the search to a specific time window#68tandav wants to merge 3 commits into
--start and per-file trim/start flags for narrowing the search to a specific time window#68tandav wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Lets the user search within an arbitrary time window of each input file, not just the first N seconds. The reported offset is always in the original (un-trimmed) file's coordinates so results are directly comparable across runs.
--start seconds(default 0) — skip the first N seconds of each input file. Combined with--trim, the considered window is[start, start + trim]. Implemented by passing the value to ffmpeg's-ss.--trim-of/--trim-within— per-file overrides for--trim, applied to the--find-offset-ofand--withinfiles respectively.--start-of/--start-within— per-file overrides for--start, same convention.time_offsetis shifted bystart_within − start_ofso it points into the original--withinfile, not the trimmed buffer. A newtime_offset_shiftkey on the result dict records the applied shift. The plot's x-axis is shifted by the same amount so the marked peak agrees with the printed offset.The library function
find_offset_between_filesgained matching kwargs (trim1,trim2,start1,start2); sharedtrim/startremain as the defaults for both files.Why
The existing
--trimonly narrows the search to the start of each file. Real-world use cases (finding a short excerpt in a long recording) often need:Example
Searches only seconds 320–380 of
long-recording.wav, prints e.g.Offset: 334.608 (seconds)— same value you'd get from searching the whole file.Test plan
pytest tests/— all 10 tests pass, including 3 new ones covering: shared--start(offset preserved under symmetric shift, auto-correlation), per-file--start-within(offset reported in original-file coords), CLI flag wiring.--start-within 320 --trim-within 60on the r4/r4_excerpt fixture returns334.608(matches the un-trimmed result).Backward compatibility
start=0, all per-file kwargsNone) reproduce the existing behavior exactly.time_offset_shift) are additive.🤖 Generated with Claude Code