Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix VTT cue timing in HLS #4217

Merged

Conversation

joeyparrish
Copy link
Member

Since the transition to sequence mode for HLS in v4.0.0, VTT cue
timings were broken. This is mainly because VTT cue timing in HLS is
meant to be based on an offset from the media timestamps, and we
generally don't know those now that we use sequence mode.

To fix it, this change uses MediaSource segment mode for the very
first video segment as a way to extract the timestamp, then clears the
buffer, switches to sequence mode, and appends it again. This lets us
get the timing data we need, while avoiding major drawbacks of the
previous HLS implementation:

  • We don't need to fetch segments upfront (which is high latency)
  • We don't need to fetch segments twice (once for timestamps, and
    once again to buffer)
  • We don't need to maintain parsers (which were complex and limited
    the formats we could support)

Closes #4191

Since the transition to sequence mode for HLS in v4.0.0, VTT cue
timings were broken.  This is mainly because VTT cue timing in HLS is
meant to be based on an offset from the media timestamps, and we
generally don't know those now that we use sequence mode.

To fix it, this change uses MediaSource segment mode for the very
first video segment as a way to extract the timestamp, then clears the
buffer, switches to sequence mode, and appends it again.  This lets us
get the timing data we need, while avoiding major drawbacks of the
previous HLS implementation:
 - We don't need to fetch segments upfront (which is high latency)
 - We don't need to fetch segments twice (once for timestamps, and
   once again to buffer)
 - We don't need to maintain parsers (which were complex and limited
   the formats we could support)

Closes shaka-project#4191
@joeyparrish joeyparrish added type: bug Something isn't working correctly component: HLS The issue involves Apple's HLS manifest format component: WebVTT The issue involves WebVTT subtitles specifically labels May 11, 2022
lib/media/media_source_engine.js Outdated Show resolved Hide resolved
lib/media/media_source_engine.js Outdated Show resolved Hide resolved
@joeyparrish joeyparrish merged commit 5818260 into shaka-project:main May 11, 2022
@joeyparrish joeyparrish deleted the sequence-mode-text-alignment branch May 11, 2022 22:26
joeyparrish added a commit that referenced this pull request May 17, 2022
Since the transition to sequence mode for HLS in v4.0.0, VTT cue
timings were broken.  This is mainly because VTT cue timing in HLS is
meant to be based on an offset from the media timestamps, and we
generally don't know those now that we use sequence mode.

To fix it, this change uses MediaSource segment mode for the very
first video segment as a way to extract the timestamp, then clears the
buffer, switches to sequence mode, and appends it again.  This lets us
get the timing data we need, while avoiding major drawbacks of the
previous HLS implementation:
 - We don't need to fetch segments upfront (which is high latency)
 - We don't need to fetch segments twice (once for timestamps, and
   once again to buffer)
 - We don't need to maintain parsers (which were complex and limited
   the formats we could support)

Closes #4191
nyanmisaka added a commit to nyanmisaka/shaka-player that referenced this pull request Oct 6, 2022
avelad pushed a commit that referenced this pull request Mar 16, 2023
…eam (#5079)

The VTT cue timing fix in
#4217 seems to have
caused a regression for videos without VTT streams, where the first
segment would sometimes not play smoothly. It also appears to fix the
gap jumping seen in the "Art of Motion (HLS, TS)" demo. This was
partially fixed for fMP4 in
#4553 but didn't fix
the issue for MPEG-2 TS.

Fixes #4975.
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: HLS The issue involves Apple's HLS manifest format component: WebVTT The issue involves WebVTT subtitles specifically status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v4.0.0 shaka player cannot display webvtt caption for HLS(either fmp4 or mpegts), DASH is fine
2 participants