av-merge: Use tickEnd+1 when calculating segment time ranges
tickEnd is inclusive, so two segments might have the following ticks: -- Segment 0 -- tickStart: 0 tickEnd: 44099 -- Segment 1 -- tickStart: 44100 tickEnd: 88199 When doing calculations in seconds about segment extent, there were gaps between segment 0's end and segment 1's beginning. This sometimes resulted in errors of not finding the corresponding segment index inside these gaps. Using (tickEnd+1)/this.sidx.timeScale is the correct method. Signed-off-by: Jesús <heckyel@hyperbola.info>
This commit is contained in:
parent
9d3ebca622
commit
aacbf07ad7
@ -225,7 +225,7 @@ Stream.prototype.appendSegment = function(segmentIdx, chunk) {
|
|||||||
while (numDeleted < 3 && i < currentSegment) {
|
while (numDeleted < 3 && i < currentSegment) {
|
||||||
let entry = this.sidx.entries[i];
|
let entry = this.sidx.entries[i];
|
||||||
let start = entry.tickStart/this.sidx.timeScale;
|
let start = entry.tickStart/this.sidx.timeScale;
|
||||||
let end = entry.tickEnd/this.sidx.timeScale;
|
let end = (entry.tickEnd+1)/this.sidx.timeScale;
|
||||||
if (entry.have) {
|
if (entry.have) {
|
||||||
this.reportWarning('Deleting segment', i);
|
this.reportWarning('Deleting segment', i);
|
||||||
this.sourceBuffer.remove(start, end);
|
this.sourceBuffer.remove(start, end);
|
||||||
@ -248,7 +248,7 @@ Stream.prototype.getSegmentIdx = function(videoTime) {
|
|||||||
// go up or down to find correct index
|
// go up or down to find correct index
|
||||||
while (index >= 0 && index < this.sidx.entries.length) {
|
while (index >= 0 && index < this.sidx.entries.length) {
|
||||||
var entry = this.sidx.entries[index];
|
var entry = this.sidx.entries[index];
|
||||||
if (entry.tickStart <= currentTick && entry.tickEnd >= currentTick){
|
if (entry.tickStart <= currentTick && (entry.tickEnd+1) > currentTick){
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
index = index + increment;
|
index = index + increment;
|
||||||
@ -296,7 +296,7 @@ Stream.prototype.segmentInBuffer = function(segmentIdx) {
|
|||||||
var entry = this.sidx.entries[segmentIdx];
|
var entry = this.sidx.entries[segmentIdx];
|
||||||
// allow for 0.01 second error
|
// allow for 0.01 second error
|
||||||
var timeStart = entry.tickStart/this.sidx.timeScale + 0.01;
|
var timeStart = entry.tickStart/this.sidx.timeScale + 0.01;
|
||||||
var timeEnd = entry.tickEnd/this.sidx.timeScale - 0.01;
|
var timeEnd = (entry.tickEnd+1)/this.sidx.timeScale - 0.01;
|
||||||
var timeRanges = this.sourceBuffer.buffered;
|
var timeRanges = this.sourceBuffer.buffered;
|
||||||
for (var i=0; i < timeRanges.length; i++) {
|
for (var i=0; i < timeRanges.length; i++) {
|
||||||
if (timeRanges.start(i) <= timeStart && timeEnd <= timeRanges.end(i)) {
|
if (timeRanges.start(i) <= timeStart && timeEnd <= timeRanges.end(i)) {
|
||||||
@ -311,7 +311,8 @@ Stream.prototype.fetchSegment = function(segmentIdx) {
|
|||||||
this.reportDebug(
|
this.reportDebug(
|
||||||
'Fetching segment', segmentIdx, ', bytes',
|
'Fetching segment', segmentIdx, ', bytes',
|
||||||
entry.start, entry.end, ', seconds',
|
entry.start, entry.end, ', seconds',
|
||||||
entry.tickStart/this.sidx.timeScale, entry.tickEnd/this.sidx.timeScale
|
entry.tickStart/this.sidx.timeScale,
|
||||||
|
(entry.tickEnd+1)/this.sidx.timeScale
|
||||||
)
|
)
|
||||||
fetchRange(
|
fetchRange(
|
||||||
this.url,
|
this.url,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user