feat: manual "Remove Silence" auto-trim in the timeline - #27
Merged
Conversation
Adds automatic silence/dead-air detection and removal, as an explicit, user-triggered timeline toolbar action - never automatic, never on by default. Per explicit product direction: streamers and tutorial-makers often go quiet on purpose while performing an on-screen action, so this must only ever run when the user deliberately asks for it, and the user picks which audio track decides "this is silence" themselves rather than the app guessing a mic-vs-system-audio heuristic. - silenceDetection.ts: pure, fully unit-tested RMS/energy-based silence span detection (-40dB threshold, 700ms minimum gap, 120ms padding kept on each side so words aren't clipped) plus a pure interval-subtraction function that splits existing ClipRegions around detected spans - mirrors the app's existing manual split+delete trim semantics exactly, so the derived TrimRegion/export/playback pipeline picks up the result with no further changes. - silenceAudioSource.ts: thin, untested I/O layer - discovers which audio sources actually exist for a recording (separate mic/system-audio sidecar files, or just the embedded/mixed track) and decodes the user-chosen one to raw PCM via the Web Audio API. - VideoEditor.tsx: a new toolbar button opens a track picker (only shows tracks that were confirmed to exist) and applies the detected cuts as real, undoable ClipRegion edits - same undo/redo path as every other timeline edit, with overlapping zoom/annotation/speed/audio regions purged the same way manual clip deletion already does it. Verified live against a packaged build with a real recording containing actual speech and pauses: detected 8 silence gaps and correctly split a single 24.5s clip into 9 surviving segments with plausible gap durations for the configured threshold; confirmed Undo fully reverts the operation back to the original single clip.
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
ClipRegionsplit (mirroring the app's existing manual split+delete trim pattern exactly) — fully undoable/draggable/deletable like any other edit, no new data model, no exporter changes needed.Test plan
npx tsc -p tsconfig.json --noEmit— cleannpx vitest --run— 834/834 passing (15 new tests covering the pure detection/region-subtraction logic: threshold/min-duration/padding edge cases, multi-channel handling, span-at-boundary id preservation, full-clip removal, multi-span splitting)