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

Shaka stops display webvtt subtitles when webvtt cue-time is greater than 2^33 (~26h30m43s) #6320

Closed
chihchianglu-google opened this issue Mar 4, 2024 · 12 comments · Fixed by #6397
Assignees
Labels
component: captions/subtitles The issue involves captions or subtitles component: HLS The issue involves Apple's HLS manifest format component: WebVTT The issue involves WebVTT subtitles specifically priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@chihchianglu-google
Copy link

Have you read the FAQ and checked for duplicate open issues?
Yes.

If the problem is related to FairPlay, have you read the tutorial?
Not related to FairPlay.

What version of Shaka Player are you using?
v4.7.11 (uncompiled)
Btw, I tried almost all the versions since v3, and none of them works.

Can you reproduce the issue with our latest release version?
Yes, v4.7.11 is the latest build / version as of 3/4/2024.

Can you reproduce the issue with the latest code from main?
Yes, I tried it on nightly build page (which should be the main).

Are you using the demo app or your own custom app?
I try it on demo page and nightly build page

If custom app, can you reproduce the issue using our demo app?
Not custom app.

What browser and OS are you using?
Chrome on MacOS 14.3.1 (23D60)

For embedded devices (smart TVs, etc.), what model and firmware version are you using?
Not on embedded devices.

What are the manifest and license server URIs?
HLS + FMP4: link
HLS + TS: link
DASH + FMP4: link

What configuration are you using? What is the output of player.getConfiguration()?
Simply paste the manifest links on shaka player demo page w/o changing any configuration.

What did you do?
Paste the HLS manifest links to shaka player demo page, and starting from 56~58 seconds, you will start seeing subtitles not showing (safari native player, hls.js, and bitmovin are all playing w/o issues).

What did you expect to happen?
Subtitles keeps showing throughout the whole stream w/o issues.

What actually happened?
The issue happens when webvtt cue-time is greater than 2^33 (roughly 26h30m43s), which is the mpegts wraparound time.
Currently, Shaka always applies this logic that tries to calculate and apply the offset if cue-time is greater than 2^33(roughly 26h30m43s), and it's not right, because in FMP4, there's no timestamp wraparound.
With this logic, the playback seeking time is wrong, thus no subtitles display after that point.

To make sure my assumption is correct:

  1. I created a hacked live stream to reproduce the issue, by starting the stream with timestamp that's ~60 seconds smaller than 2^33, and after ~60 seconds, shaka fails to show subtitles while safari native player, hls.js, and bitmovin are all playing w/o issues. You should see the same behavior from the manifests I provided above.

  2. DASH shouldn't run into the same issue because the shaka code I highlighted above only applies to HLS, and if you check the DASH manifest I provided above, it's indeed playing w/o issues.

Let me know if you need anything further from me, thanks.

@chihchianglu-google chihchianglu-google added the type: bug Something isn't working correctly label Mar 4, 2024
@chihchianglu-google chihchianglu-google changed the title Shaka stops display webvtt subtitles when webvtt cue-time is greater than 2^33 Mar 4, 2024
@joeyparrish joeyparrish added component: HLS The issue involves Apple's HLS manifest format component: captions/subtitles The issue involves captions or subtitles priority: P1 Big impact or workaround impractical; resolve before feature release component: WebVTT The issue involves WebVTT subtitles specifically labels Mar 4, 2024
@joeyparrish joeyparrish self-assigned this Mar 4, 2024
@shaka-bot shaka-bot added this to the v5.0 milestone Mar 5, 2024
@joeyparrish
Copy link
Member

Confirmed repro. Thanks for the report! The stream URLs make this much easier to work on.

Currently, Shaka always applies this logic that tries to calculate and apply the offset if cue-time is greater than 2^33(roughly 26h30m43s), and it's not right, because in FMP4, there's no timestamp wraparound.

I believe you are correct. I suppressed the rollover logic in the debug console by setting shaka.text.VttTextParser.TS_ROLLOVER_ = Infinity, and I see subs throughout the HLS+MP4 clip.

I tried the HLS+TS clip, but it hangs at the rollover point with errors about bad timestamps in the media. There might be an issue with our transmuxer here.

@joeyparrish
Copy link
Member

The HLS+TS clip plays in v4.4.0 and v4.5.0, but not in v4.6.0, v4.7.0, or v4.7.11 (latest).

In the versions where the HLS+TS doesn't hang at the rollover point, we still need the shaka.text.VttTextParser.TS_ROLLOVER_ = Infinity hack to suppress the rollover logic in the VTT parser, which makes sense because we're transmuxing TS to MP4 in Chrome. (We may still need the rollover logic for native TS playback.)

Probably the HLS+TS hang is caused by a transmuxer change introduced between v4.5.0 and v4.6.0. I'll narrow that down further.

@joeyparrish
Copy link
Member

No bug fix releases were made to v4.5.x before v4.6.0 came out. So the culprit for the media hanging must be one of the changes in v4.6.0:

https://github.com/shaka-project/shaka-player/releases/tag/v4.6.0

@joeyparrish
Copy link
Member

The transmuxer bug that impacts the HLS+TS stream begins with ae423b4, PR #5846. @avelad, I would love your input on this when you are available.

I can work on the VTT rollover, though. Making the rollover logic conditional is easy enough, but the condition is whether or not we're playing TS. Plumbing that knowledge into the parser may be ugly. But I'll figure it out.

@joeyparrish
Copy link
Member

@chihchianglu-google, you can work around this issue with the following configuration:

player.configure('manifest.hls.sequenceMode', false);

This can cause issues with certain HLS content if the timestamps in the media are wrong, but I suspect the streams you are creating will be just fine.

Does this work for you as a workaround for now? Can you test this, and if it is robust enough for you, can you recommend this to your customers?


@avelad, related to this issue, we should discuss:

  1. If we should always enable the transmuxer for TS content, because that would remove the need for new data plumbed to VTTTextParser and allow us to completely drop the rollover logic
  2. What part of the TS transmuxer optimizations from fix: Fix nalu parsing and improve performance in the transmuxer #5846 could be causing the hang that appears in https://storage.googleapis.com/livestream-demo-output/ccl-webvtt-test/manifest-ts.m3u8 at the rollover point, around the 55-60 second mark, with errors about bad timestamps

Thanks!

@joeyparrish joeyparrish added priority: P2 Smaller impact or easy workaround and removed priority: P1 Big impact or workaround impractical; resolve before feature release labels Mar 5, 2024
@joeyparrish
Copy link
Member

Lowering priority to P2 based on the configuration workaround, assuming acceptance of that workaround by the OP

@chihchianglu-google
Copy link
Author

@joeyparrish , the config seems not working for me. Here's the player link.
I simply uncheck the config from UI, and I can see that reflect in the player URL above.
However, after that, all the subtitles are gone.

@avelad
Copy link
Collaborator

avelad commented Mar 6, 2024

@avelad, related to this issue, we should discuss:

1. If we should always enable the transmuxer for TS content, because that would remove the need for new data plumbed to VTTTextParser and allow us to completely drop the rollover logic

I think it would be the best given the number of issues there are with the native TS.

2. What part of the TS transmuxer optimizations from [fix: Fix nalu parsing and improve performance in the transmuxer #5846](https://github.com/shaka-project/shaka-player/pull/5846) could be causing the hang that appears in https://storage.googleapis.com/livestream-demo-output/ccl-webvtt-test/manifest-ts.m3u8 at the rollover point, around the 55-60 second mark, with errors about bad timestamps

The problem is that we do not have pes-rollover implemented in the tsparser and tstransmuxer, we should implement it. I can work on it in 3 weeks, if that's okay with you.

@joeyparrish
Copy link
Member

@joeyparrish , the config seems not working for me. Here's the player link. I simply uncheck the config from UI, and I can see that reflect in the player URL above. However, after that, all the subtitles are gone.

@chihchianglu-google, you are right. I was mistaken. I must have made a mistake while testing yesterday. Bumping back to P1.

@avelad wrote:

The problem is that we do not have pes-rollover implemented in the tsparser and tstransmuxer, we should implement it. I can work on it in 3 weeks, if that's okay with you.

@chihchianglu-google, the TS parser fix will have to wait until @avelad is available to work on it. Thanks for your understanding!

@joeyparrish joeyparrish added priority: P1 Big impact or workaround impractical; resolve before feature release and removed priority: P2 Smaller impact or easy workaround labels Mar 6, 2024
@joeyparrish
Copy link
Member

I did some more digging and found that the timestamp logic was working in v4.2.0 - v4.2.2, but not in v4.2.3 or v4.3.0. This was the change responsible AFAICT: 3b9af2e, PR #4586, which mentions internal bug b/253104251 in the regression test.

If I remove the rollover logic entirely, that regression test will fail. It's not clear to me yet how to proceed. I don't have access to the original streams that led to that change, only the regression test that simulates them.

@chihchianglu-google
Copy link
Author

Just my 2 cents.
I feel the issue of the webvtt in shaka is because it doesn't know the corresponding media (video/audio) segment timestamp. If it does, the calculation probably could be more generic w/o many corner cases because X-TIMESTAMP-MAP is just a timestamp mapping between vtt cue-time and media segment timestamp.

joeyparrish added a commit to joeyparrish/shaka-player that referenced this issue Mar 6, 2024
This moves VTT sequence mode offset calculations into a method.

It also makes all X-TIMESTAMP-MAP usage dependent on HLS specifically,
rather than sequence mode, simplifying the conditions.  Sequence mode
is typically only used with HLS, and X-TIMESTAMP-MAP is explicitly
only for HLS.  So excluding X-TIMESTAMP-MAP for DASH made sense.

This required updating some tests to explicitly set both the manifest
type and sequence mode flag.

This does *not* change the offset calculations themselves.  Changes
will be made in follow-up PRs.

Issue shaka-project#6320
joeyparrish added a commit that referenced this issue Mar 7, 2024
This moves VTT sequence mode offset calculations into a method.

It also makes all X-TIMESTAMP-MAP usage dependent on HLS specifically,
rather than sequence mode, simplifying the conditions. Sequence mode is
typically only used with HLS, and X-TIMESTAMP-MAP is explicitly only for
HLS. So excluding X-TIMESTAMP-MAP for DASH makes sense, instead of
conflating HLS and sequence mode.

This required updating some tests to explicitly set both the manifest
type and sequence mode flag.

This does *not* change the offset calculations themselves. Changes will
be made in follow-up PRs.

Issue #6320
@joeyparrish
Copy link
Member

Just my 2 cents. I feel the issue of the webvtt in shaka is because it doesn't know the corresponding media (video/audio) segment timestamp. If it does, the calculation probably could be more generic w/o many corner cases because X-TIMESTAMP-MAP is just a timestamp mapping between vtt cue-time and media segment timestamp.

You're not wrong, but it's more complicated than that for many reasons.

  1. The same VTT file can be used in both HLS and DASH. In DASH, X-TIMESTAMP-MAP should be ignored. (In fact, in DASH, according to DASH InterOp Points (IOP), you should only ever use VTT segments wrapped in MP4, which have their own timestamps in the MP4.)
  2. "Knowing" the media segment timestamp in a VTT parser is architecturally weird. The VTT parser shouldn't have to know things about video stream.
  3. The "corresponding" media segment is ill-defined. Segments are not required to align at all. I could have 10s text segments and 2s video segments. Which of these 5 segments "corresponds" to this text segment? (Or the two durations could be co-prime, or the segments sizes could change on every single segment...)

We have HLS live streams in the demo app, but none of them have subtitles. So I don't have any real-world examples at hand to compare the formatting and timestamps of different live streaming solutions to vet any changes I make.

I'm looking more closely at the HLS spec so I can try to adjust the logic based on that.

avelad added a commit that referenced this issue Apr 3, 2024
Related to #6334
Related to
#6320 (comment)
Also reverts #6045
since now it is not necessary
avelad pushed a commit that referenced this issue Apr 8, 2024
This moves VTT sequence mode offset calculations into a method.

It also makes all X-TIMESTAMP-MAP usage dependent on HLS specifically,
rather than sequence mode, simplifying the conditions. Sequence mode is
typically only used with HLS, and X-TIMESTAMP-MAP is explicitly only for
HLS. So excluding X-TIMESTAMP-MAP for DASH makes sense, instead of
conflating HLS and sequence mode.

This required updating some tests to explicitly set both the manifest
type and sequence mode flag.

This does *not* change the offset calculations themselves. Changes will
be made in follow-up PRs.

Issue #6320
avelad added a commit that referenced this issue Apr 8, 2024
avelad added a commit that referenced this issue Apr 8, 2024
Related to #6334
Related to
#6320 (comment)
Also reverts #6045
since now it is not necessary
avelad pushed a commit that referenced this issue Apr 8, 2024
This moves VTT sequence mode offset calculations into a method.

It also makes all X-TIMESTAMP-MAP usage dependent on HLS specifically,
rather than sequence mode, simplifying the conditions. Sequence mode is
typically only used with HLS, and X-TIMESTAMP-MAP is explicitly only for
HLS. So excluding X-TIMESTAMP-MAP for DASH makes sense, instead of
conflating HLS and sequence mode.

This required updating some tests to explicitly set both the manifest
type and sequence mode flag.

This does *not* change the offset calculations themselves. Changes will
be made in follow-up PRs.

Issue #6320
avelad added a commit that referenced this issue Apr 8, 2024
avelad added a commit that referenced this issue Apr 8, 2024
Related to #6334
Related to
#6320 (comment)
Also reverts #6045
since now it is not necessary
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Jun 3, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Jun 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: captions/subtitles The issue involves captions or subtitles component: HLS The issue involves Apple's HLS manifest format component: WebVTT The issue involves WebVTT subtitles specifically priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
4 participants