Skip to content

@remotion/media: Bound unshifted audio decoding to the sequence end - #12695

Merged
samohovets merged 4 commits into
mainfrom
bound-audio-to-sequence-end
Oct 29, 2026
Merged

samohovets merged 4 commits into
mainfrom
bound-audio-to-sequence-end

Conversation

@samohovets

Copy link
Copy Markdown
Member

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.

  • Short non-looping <Audio> / <Video> clips no longer decode source audio beyond their sequence end. Looping and pitch-shifted audio keep their existing bounds.
  • Changing the sequence duration destroys the audio iterator before seeking, so extending a clip decodes the newly added span.

New media-player.test.ts cases cover Audio/Video, trims, 0.5×/1×/2× rates, loops, and extend → shrink → re-extend. 5 of them fail without the fix.

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>
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bugs Ready Ready Preview Oct 29, 2026 1:06pm UTC
remotion Ready Ready Preview Oct 29, 2026 1:06pm UTC

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Bound unshifted audio decoding to the sequence end — audio-iterator-manager.ts now caps the non-looping, pitch-free unshifted iterator at Math.min(getMediaEndTimestamp(), getSequenceEndTimestamp()) instead of the full media end, so short clips stop decoding audio that can never play. The value feeds both the startFromSecond >= maximumTimestamp early-return and makeIteratorWithPriming, both in media seconds, and getSequenceEndTimestamp() already includes trimBefore and playbackRate, so the bound lines up with the existing onAudioChunk clamp.
  • Invalidate the iterator on sequence-duration change — media-player.ts:803 destroys the audio iterator before the duration-change seekTo(..., 'discontinuity'), matching the existing setLoop / setTrimRange / setPlaybackRate / setGlobalPlaybackRate pattern, so extending a clip decodes the newly added span rather than retaining the exhausted capped iterator.
  • Regression coverage — media-player.test.ts extends the helper to forward loop / trimBefore / trimAfter / playbackRate / durationInFrames and adds real-codec Audio and Video cases across trims, 0.5×/1×/2×, a sub-MINIMUM_AUDIO_BUFFERING_TIME_SECONDS clip, 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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

@samohovets
samohovets merged commit 36b99ff into main Oct 29, 2026
19 checks passed
@samohovets
samohovets deleted the bound-audio-to-sequence-end branch October 29, 2026 14:01

This branch was successfully deployed

2 active deployments
Preview – remotion — 9e1b7206 Deployed Oct 29, 2026 by vercel[bot]
Preview – bugs — 9e1b7206 Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants