fix(media-use): remove clicks and ~25ms gaps at every transcript-cut splice - #4179
Open
larrylicuanan2488-wq wants to merge 1 commit into
Open
larrylicuanan2488-wq wants to merge 1 commit into
larrylicuanan2488-wq wants to merge 1 commit into
Conversation
…splice transcript-cut extracts each kept range to its own final-codec file, then concat-copies them. That produces two audible artifacts at every cut: 1. No boundary fades. Concat splices raw segment edges together, so the waveform steps discontinuously and each cut clicks. 2. Encoder priming silence. Each segment is encoded to AAC independently, so the encoder pads every one with priming samples. Stream-copy concat bakes that padding in as a silent gap at each splice. Measured 24.4 ms and 24.1 ms at the two splices of a three-range cut. It accumulates: the nth splice lands roughly 25n ms late, so splice positions drift away from the sum of the preceding segment durations. The second survives the first -- adding fades alone leaves the gap. Fix: intermediates carry PCM (.mkv for video, .wav for audio-only) instead of the final codec, so audio is encoded exactly once, at concat. Boundary fades of 30 ms are applied per segment, scaled down on segments shorter than 4x the ramp and skipped on degenerate ones. Measured on the same three-range cut, widest run of digital silence at each splice: before 24.4 ms / 24.1 ms after 0.1 ms / 0.1 ms --copy is unchanged: stream copy cannot filter, so it keeps producing final-codec segments and a copy concat. Audio-only output is byte-identical in duration before and after. scripts/lib test suite: 34/35, the one failure (lut-preset-provider) pre-exists on main and is unrelated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
miguel-heygen
approved these changes
Sep 19, 2026
miguel-heygen
enabled auto-merge (squash)
September 19, 2026 16:06
Collaborator
|
The failing check is Skills: manifest in sync. Please regenerate and commit the root manifest with: This updates the |
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.
The problem
skills/media-use/scripts/transcript-cut.mjsextracts each kept range to its own final-codec file, then concat-copies them. Two audible artifacts result at every cut, and they are separate bugs:The second survives the first. Adding fades alone still leaves the gap, which is what made it easy to miss.
Reproduce
node skills/media-use/scripts/transcript-cut.mjs \ --input take.mp4 --transcript take.json --keep "5-10,20-25,40-45" --out out.mp4Widest run of digital silence within ±0.25 s of each nominal splice:
The fix
Intermediates carry PCM (
.mkvfor video,.wavfor audio-only) rather than the final codec, so audio is encoded exactly once — at concat. Per-segment 30 msafadein/out ramps handle the click, scaled down on segments shorter than 4× the ramp and skipped on degenerate ones.Not changed
--copy— stream copy cannot filter, so it still produces final-codec segments and a copy concat. The flag already trades accuracy for speed; this leaves that trade alone..wavintermediates avoid the aac-in-wav timing break the existingencodeArgsForcomment warns about.Verification
scripts/lib/*.test.mjs: 34/35. The one failure,lut-preset-provider.test.mjs, reproduces on unmodifiedmainand is unrelated (it reads apackages/core/src/colorGrading.tsthat does not exist in this repo).🤖 Generated with Claude Code