From 9d3ebca622f7eddd3539e4532957dcf8487feb72 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 28 Aug 2021 09:23:19 -0700 Subject: av-merge: End stream correctly when last segments do not overlap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this video at 480p: https://www.youtube.com/watch?v=6bnanI9jXps There is an extremely tiny audio segment from 30.00018140589569 to 30.06981859410431 after the last video segment ends at 29.99998888888889. Call end of stream when we have all segments until the end, instead of calling it when we are playing the last segment. Signed-off-by: Jesús --- youtube/static/js/av-merge.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'youtube') diff --git a/youtube/static/js/av-merge.js b/youtube/static/js/av-merge.js index f6ea007..84e121c 100644 --- a/youtube/static/js/av-merge.js +++ b/youtube/static/js/av-merge.js @@ -283,10 +283,9 @@ Stream.prototype.checkBuffer = async function() { if (i < this.sidx.entries.length && !this.sidx.entries[i].requested) { this.fetchSegment(i); - // We are playing the last segment and we have it. + // We have all the segments until the end // Signal the end of stream - } else if (currentSegmentIdx == this.sidx.entries.length - 1 - && this.sidx.entries[currentSegmentIdx].have) { + } else if (i == this.sidx.entries.length) { if (this.streamType == 'audio') this.avMerge.audioEndOfStream(); else -- cgit v1.2.3