Skip to content

Commit

Permalink
Subtitle end timestamps are not inclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
killergerbah committed Aug 4, 2024
1 parent 566e2ac commit f1904e1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/subtitle-collection/subtitle-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ export class SubtitleCollection<T extends SubtitleModel> {
}

for (const s of subtitles) {
this.tree.insert([s.start, s.end], s);
if (s.start < s.end) {
this.tree.insert([s.start, s.end - 1], s);
}

if (last !== undefined && last.end < s.start) {
this.gapsTree.insert([last.end + 1, s.start - 1], last);
this.gapsTree.insert([last.end, s.start - 1], last);
}

last = s;
Expand Down Expand Up @@ -80,7 +82,7 @@ export class SubtitleCollection<T extends SubtitleModel> {
}
} else if (this.options.showingCheckRadiusMs !== undefined) {
for (const s of showing) {
if (willStopShowing === undefined && s.end < timestamp + this.options.showingCheckRadiusMs) {
if (willStopShowing === undefined && s.end <= timestamp + this.options.showingCheckRadiusMs) {
willStopShowing = s;
}

Expand Down

0 comments on commit f1904e1

Please sign in to comment.