Repository navigation
Conversation
The silence-fill guard compared nextPts against 0, but nextPts is an absolute input-timescale value that includes initPTS, so fill frames could land before the start of the timeline. After the controller applies timestampOffset = -initPTS such a frame has a negative presentation time: WebKit drops it and Chromium trims it, while the fragment's startPTS reports a start that is not in the buffer. Comparing against initTime drops only the frames that would land before 0.
2 of 3 tasks
robwalch
approved these changes
Oct 22, 2026
Collaborator
|
Thanks for the fix. This was missed in #7311. |
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.
This PR will...
Stop the AAC silence fill in
remuxAudiofrom placing injected frames before the start of the timeline. The guard that trims fill frames comparesnextPtsagainst0, butnextPtsis an absolute input-timescale value that includesinitPTS, so the comparison never fires. It now compares againstinitTime.Why is this Pull Request needed?
With B-frames, initPTS anchors on the first video DTS and the first audio sample can start one or more audio frames later. On a 29.97 fps iPhone encode (libx264 defaults, 44.1 kHz AAC) the first audio PTS is 6006 ticks (67 ms) after initPTS, so the fill rounds to three frames and places the first one 263 ticks (2.9 ms) before initPTS. The log reads
Injecting 3 audio frames @ -0.003s.After the controller applies
timestampOffset = -initPTS, that frame has a negative presentation time. WebKit (MediaSource and ManagedMediaSource, measured on headless WebKit 26.4) drops it, so the audio buffered range starts at 0.020 instead of where the fragment says it starts; Chromium trims it. Either way the fragment'sstartPTSis negative and describes a frame that is not in the buffer. With the fix, two frames are injected and the track starts 20 ms after initPTS, which matches what ends up buffered.Are there any points in the code the reviewer needs to double check?
nextPtsis absolute at this point (nextAudioTs + initTimeat loop start, andpts - missing * inputSampleDurationhere), soinitTimeis the right zero. The subsequentthis.nextAudioTs = nextAudioTs = nextPts - initTimeoni === 0already treats it that way.Resolves issues:
Checklist