Repository navigation
@remotion/media: Bound unshifted audio decoding to the sequence end - #12695
Merged
Merged
Conversation
Short non-looping Audio and Video clips no longer decode source audio past their sequence end. Extending a clip's duration recreates the audio iterator so the newly added span is decoded. Supersedes #12683. Co-authored-by: Alec Watts <alecwatts1@gmail.com>
Contributor
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Bound unshifted audio decoding to the sequence end —
audio-iterator-manager.tsnow caps the non-looping, pitch-free unshifted iterator atMath.min(getMediaEndTimestamp(), getSequenceEndTimestamp())instead of the full media end, so short clips stop decoding audio that can never play. The value feeds both thestartFromSecond >= maximumTimestampearly-return andmakeIteratorWithPriming, both in media seconds, andgetSequenceEndTimestamp()already includestrimBeforeandplaybackRate, so the bound lines up with the existingonAudioChunkclamp. - Invalidate the iterator on sequence-duration change —
media-player.ts:803destroys the audio iterator before the duration-changeseekTo(..., 'discontinuity'), matching the existingsetLoop/setTrimRange/setPlaybackRate/setGlobalPlaybackRatepattern, so extending a clip decodes the newly added span rather than retaining the exhausted capped iterator. - Regression coverage —
media-player.test.tsextends the helper to forwardloop/trimBefore/trimAfter/playbackRate/durationInFramesand adds real-codec Audio and Video cases across trims, 0.5×/1×/2×, a sub-MINIMUM_AUDIO_BUFFERING_TIME_SECONDSclip, unchanged loop bounds, and extend → shrink → re-extend.
The looping and pitch-shifted paths deliberately keep their previous getMediaEndTimestamp() bound; the currentToneFrequency !== 1 exception is justified by the existing pitch-preview regression (the streaming shifter reads ahead of the segment). Short clips that fall below the buffering threshold still unblock on iterator completion via onDone, which the 1-frame/0.5× case covers. No behavioral regressions found in the touched paths.
deepseek-v4.1-flash | 𝕏
This branch was successfully deployed
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.

Supersedes #12683 by @alec-watts (the fork doesn't allow maintainer edits). Same fix, rebased on main, without the fixture changes that already landed in #12685 and without the implementation comments.
<Audio>/<Video>clips no longer decode source audio beyond their sequence end. Looping and pitch-shifted audio keep their existing bounds.New
media-player.test.tscases cover Audio/Video, trims, 0.5×/1×/2× rates, loops, and extend → shrink → re-extend. 5 of them fail without the fix.