Skip to content

Commit

Permalink
Merge pull request #17 from Pluto-tv/feature/WEBTECH-12437
Browse files Browse the repository at this point in the history
added: cherry picked code from WEBTECH-6432
  • Loading branch information
gar7and authored Mar 9, 2021
2 parents b3587f0 + 82d2a8a commit 475622b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/controller/subtitle-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,30 @@ export class SubtitleStreamController extends BaseStreamController {
if (!foundFrag) {
foundFrag = findFragmentByPTS(fragPrevious, fragments, bufferEnd, maxFragLookUpTolerance);
}
if (!foundFrag && trackDetails.live && fragPrevious && fragPrevious.start < fragments[0].start) {
/*
below is a real world example of what can happen in production.
fragPrevious s:04:08:44.000Z, e:04:08:49.000Z -- was found by PDT
# response on subtitle/en/playlist.m3u8 on Nth call
fragments[0]: s:04:08:24.000Z, e:04:08:29.000Z -- s:4532.900002, e:4537.900002
fragments[1]: s:04:08:29.000Z, e:04:08:34.000Z -- s:4537.900002, e:4542.900002
fragments[2]: s:04:08:34.000Z, e:04:08:39.000Z -- s:4542.900002, e:4547.900002
fragments[3]: s:04:08:39.000Z, e:04:08:44.000Z -- s:4547.900002, e:4552.900002
fragments[4]: s:04:08:44.000Z, e:04:08:49.000Z -- s:4552.900002, e:4557.900002
# response on subtitle/en/playlist.m3u8 on (N+1)th call
fragments[0]: s:04:08:54.000Z, e:04:08:59.000Z -- s:4562.900002, e:4567.900002
fragments[1]: s:04:08:59.000Z, e:04:09:04.000Z -- s:4567.900002, e:4572.900002
fragments[2]: s:04:09:04.000Z, e:04:09:09.000Z -- s:4572.900002, e:4577.900002
fragments[3]: s:04:09:09.000Z, e:04:09:14.000Z -- s:4577.900002, e:4582.900002
fragments[4]: s:04:09:14.000Z, e:04:09:19.000Z -- s:4582.900002, e:4587.900002
# notice the gap from e:04:08:49.000Z to s:04:08:54.000Z, code below is to fix this issue
*/

foundFrag = fragments[0];
logger.warn(`Gap detected in live subtitle playlist, using next available fragment {start: ${foundFrag.start}}`);
}
} else {
foundFrag = fragments[fragLen - 1];
}
Expand Down

0 comments on commit 475622b

Please sign in to comment.