Skip to content

Commit

Permalink
fix: Make encoding problem detection more robust (#4885)
Browse files Browse the repository at this point in the history
Before, tiny segments (~33ms in practice) and overwritten segments
(sometimes necessary) would register as encoding problems. This makes
the logic more robust and the error logs more reliable.

Issue #4589
  • Loading branch information
joeyparrish authored Jan 12, 2023
1 parent c42565c commit 0e3621c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,13 @@ shaka.media.MediaSourceEngine = class {
bufferedBefore, bufferedAfter);
if (newBuffered) {
const segmentDuration = reference.endTime - reference.startTime;
if (Math.abs(newBuffered.start - reference.startTime) >
segmentDuration / 2) {
// Check end times instead of start times. We may be overwriting a
// buffer and only the end changes, and that would be fine.
// Also, exclude tiny segments. Sometimes alignment segments as small
// as 33ms are seen in Google DAI content. For such tiny segments,
// half a segment duration would be no issue.
const offset = Math.abs(newBuffered.end - reference.endTime);
if (segmentDuration > 0.100 && offset > segmentDuration / 2) {
shaka.log.error('Possible encoding problem detected!',
'Unexpected buffered range for reference', reference,
'from URIs', reference.getUris(),
Expand Down

0 comments on commit 0e3621c

Please sign in to comment.