fix(silence): keep negative silence_start intervals as split boundaries#178
Open
seonghobae wants to merge 1 commit into
Open
fix(silence): keep negative silence_start intervals as split boundaries#178seonghobae wants to merge 1 commit into
seonghobae wants to merge 1 commit into
Conversation
ffmpeg's silencedetect back-dates silence_start by the detection window, so a recording that begins in silence reports a slightly negative silence_start (e.g. -0.008). The parser regex only accepted [0-9]+, so the negative start failed to match, the following silence_end was orphaned, and the entire interval was silently dropped. When such a silence spans past the segment midpoint it is the best split boundary; dropping it forced an unwanted mid-audio hard split. Allow an optional leading sign in the silence_start/silence_end value patterns. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CJRVbDrp1vGYkJgNHMGPpG
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.
Why
ffmpeg's
silencedetectfilter back-datessilence_startby the detection window (d), so a recording that begins in silence reports a slightly negativesilence_start(e.g.-0.00816327) — a well-known ffmpeg quirk. The parser regex only accepted[0-9]+, so the negative value failed to match. Because.searchfound no start,current_startstayedNone, the followingsilence_endwas orphaned, and the entire silence interval was silently dropped.When such a head silence extends past the segment midpoint, it is the ideal split boundary. Dropping it forced
build_segmentsto fall back to a hard split atwindow_end - epsilon, cutting in the middle of audio instead of inside the silence.Reproduced before the fix:
What
Allow an optional leading sign (
-?) in the numeric value of thesilence_start/silence_endregexes. Smallest safe diff; no behavior change for the existing non-negative cases.Tests
test_parse_silencedetect_intervals_keeps_negative_start_at_recording_head— negativesilence_startis now parsed into a complete interval (fails on old code, returns[]).test_negative_start_silence_still_drives_split_point—build_segmentsnow splits at the silence boundary (150.5s) rather than a mid-audio hard split.Gates:
coverage100% onmedia_shrinker.py,interrogate100%, full suite green apart from the 5 pre-existing macOS-onlyos.listxattrbaseline errors.🤖 Generated with Claude Code