Skip to content

Commit

Permalink
Only load earlier subtitle fragment if discontinuity matches
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalch committed Jun 28, 2023
1 parent a567ef5 commit 11d9097
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/controller/subtitle-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,12 @@ export class SubtitleStreamController
}
foundFrag = this.mapToInitFragWhenRequired(foundFrag) as Fragment;
if (foundFrag.sn !== 'initSegment') {
// Load earlier fragment to make up for misaligned playlists and cues that extend beyond end of segment
// Load earlier fragment in same discontinuity to make up for misaligned playlists and cues that extend beyond end of segment
const curSNIdx = foundFrag.sn - trackDetails.startSN;
const prevFrag = fragments[curSNIdx - 1];
if (
prevFrag &&
prevFrag.cc === foundFrag.cc &&
this.fragmentTracker.getState(prevFrag) === FragmentState.NOT_LOADED
) {
foundFrag = prevFrag;
Expand Down
3 changes: 3 additions & 0 deletions src/controller/timeline-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ export class TimelineController implements ComponentAPI {
}
// Something went wrong while parsing. Trigger event with success false.
logger.log(`Failed to parse VTT cue: ${error}`);
if (missingInitPTS && maxAvCC > frag.cc) {
return;
}
hls.trigger(Events.SUBTITLE_FRAG_PROCESSED, {
success: false,
frag: frag,
Expand Down

0 comments on commit 11d9097

Please sign in to comment.