Skip to content

Commit

Permalink
Switch on smaller fmp4 segments that align with buffered segment boun…
Browse files Browse the repository at this point in the history
…daries

Fixes #5743
  • Loading branch information
robwalch committed Sep 7, 2023
1 parent f28a374 commit c056878
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/controller/fragment-finders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,18 @@ export function findFragmentByPTS(
fragments[
(fragPrevious.sn as number) - (fragments[0].sn as number) + 1
] || null;
// check for buffer-end rounding error
const bufferEdgeError = fragPrevious.endDTS - bufferEnd;
if (bufferEdgeError > 0 && bufferEdgeError < 0.0000015) {
bufferEnd += 0.0000015;
}
} else if (bufferEnd === 0 && fragments[0].start === 0) {
fragNext = fragments[0];
}
// Prefer the next fragment if it's within tolerance
if (
fragNext &&
(!fragPrevious || fragPrevious.level === fragNext.level) &&
fragmentWithinToleranceTest(bufferEnd, maxFragLookUpTolerance, fragNext) ===
0
) {
Expand Down
4 changes: 2 additions & 2 deletions src/controller/stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ export default class StreamController
Math.min(
Math.max(
fragDuration - this.config.maxFragLookUpTolerance,
fragDuration * 0.5,
fragDuration * (this.couldBacktrack ? 0.5 : 0.125),
),
fragDuration * 0.75,
fragDuration * (this.couldBacktrack ? 0.75 : 0.25),
),
);
this.flushMainBuffer(startPts, Number.POSITIVE_INFINITY);
Expand Down

0 comments on commit c056878

Please sign in to comment.