Skip to content

Commit

Permalink
fix(HLS): Fix subtitle timing when no discontinuity but there is X-TI…
Browse files Browse the repository at this point in the history
…MESTAMP-MAP (#7681)

Fixes #7673
  • Loading branch information
avelad authored and joeyparrish committed Dec 11, 2024
1 parent 8fa036a commit 3fa6242
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,7 @@ shaka.media.MediaSourceEngine = class {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

if (contentType == ContentType.TEXT) {
if (this.manifestType_ == shaka.media.ManifestParser.HLS &&
reference.discontinuitySequence >= 0) {
if (this.manifestType_ == shaka.media.ManifestParser.HLS) {
// This won't be known until the first video segment is appended.
const offset = await this.textSequenceModeOffset_;
this.textEngine_.setTimestampOffset(offset);
Expand Down
13 changes: 9 additions & 4 deletions lib/text/vtt_text_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ shaka.text.VttTextParser = class {
// HLS content, which should use X-TIMESTAMP-MAP and periodStart instead.
let offset = time.vttOffset;

// Only use 'X-TIMESTAMP-MAP' with HLS. This overrides offset above.
if (blocks[0].includes('X-TIMESTAMP-MAP') &&
this.manifestType_ == shaka.media.ManifestParser.HLS) {
offset = this.computeHlsOffset_(blocks[0], time);
if (this.manifestType_ == shaka.media.ManifestParser.HLS) {
// Only use 'X-TIMESTAMP-MAP' with HLS.
if (blocks[0].includes('X-TIMESTAMP-MAP')) {
offset = this.computeHlsOffset_(blocks[0], time);
} else if (time.periodStart && time.vttOffset == time.periodStart) {
// In the case where X-TIMESTAMP-MAP is not used and it is HLS, we
// should not use offset unless segment-relative times are used.
offset = 0;
}
}

// Parse VTT regions.
Expand Down

0 comments on commit 3fa6242

Please sign in to comment.