diff --git a/lib/dash/dash_parser.js b/lib/dash/dash_parser.js index 0652705fbf..d00dae49b4 100644 --- a/lib/dash/dash_parser.js +++ b/lib/dash/dash_parser.js @@ -592,7 +592,10 @@ shaka.dash.DashParser.prototype.parsePeriods_ = function( periodDuration = presentationDuration - start; } - if (periodDuration && givenDuration && periodDuration != givenDuration) { + var threshold = + shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS; + if (periodDuration && givenDuration && + Math.abs(periodDuration - givenDuration) > threshold) { shaka.log.warning('There is a gap/overlap between Periods', elem); } // Only use the @duration in the MPD if we can't calculate it. We should diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index da9bd4ca6e..cc8e59bf00 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -573,9 +573,12 @@ shaka.util.StreamUtils.getFullMimeType = function(mimeType, opt_codecs) { * @return {number} */ shaka.util.StreamUtils.findPeriodContainingTime = function(manifest, time) { + var threshold = shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS; for (var i = manifest.periods.length - 1; i > 0; --i) { var period = manifest.periods[i]; - if (time >= period.startTime) + // The last segment may end right before the end of the Period because of + // rounding issues. + if (time + threshold >= period.startTime) return i; } return 0;