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

WebVTT line cue setting not following the spec in UITextDisplayer #4567

Closed
Robloche opened this issue Oct 11, 2022 · 4 comments
Closed

WebVTT line cue setting not following the spec in UITextDisplayer #4567

Robloche opened this issue Oct 11, 2022 · 4 comments
Assignees
Labels
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

@Robloche
Copy link
Contributor

Robloche commented Oct 11, 2022

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

What version of Shaka Player are you using?
4.2.2

Can you reproduce the issue with our latest release version?
Yes.

Can you reproduce the issue with the latest code from main?
Not tried.

Are you using the demo app or your own custom app?
My custom app.

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

What browser and OS are you using?
Chrome 105.0.5195.127 (Build officiel) (64 bits)
Windows 10 Pro 21H2

What did you do?
I'm using UITextDisplayer to display WebVTT subtitles.
This particular subtitles file contains lines like:

00:04:32.760 --> 00:04:35.160 align:end position:90% line:91%,end
-J'y vais. Tu viens pas avec moi ?

What did you expect to happen?
The line should be displayed at the bottom of the screen, as per specification:
For horizontal cues, this is the vertical offset from the top of the video viewport, [...]

What actually happened?
The line appears at the top of the screen.
Inspecting the style shows me:
<div style="white-space: pre-wrap; direction: ltr; opacity: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; font-weight: 400; font-style: normal; position: absolute; left: 0px; top: 0px; width: 100%; bottom: 91%; text-align: end; writing-mode: horizontal-tb;"><span style="background-color: rgba(0, 0, 0, 0.8);">-J'y vais. Tu viens pas avec moi ?</span></div>

I guess bottom: 91% should be top: 91%.
And indeed, doing it in Chrome DevTools actually moves the line to the bottom of the screen, as expected.

@Robloche Robloche added the type: bug Something isn't working correctly label Oct 11, 2022
@github-actions github-actions bot added this to the v4.3 milestone Oct 11, 2022
@avelad avelad removed this from the v4.3 milestone Oct 13, 2022
@avelad avelad added the status: working as intended The behavior is intended; this is not a bug label Oct 13, 2022
@Robloche
Copy link
Contributor Author

After reading the specs here and here again, it appears that line:91%,end means that the bottom of the cue box is positionned at 91% of the viewport's height from the top of the viewport.
So, the subtitles should indeed appear at the bottom of the screen, but not by using top: 91% (which would be the translation of line:91%,start).

To clarify, line:91%,end means that the cue box should have a top property set to 91% - <height of cue box>.

So, it's my understanding that the problem is here:

style.bottom = cue.line + '%';

Please feel free to correct me if I misunderstood the specs.

@Robloche Robloche reopened this Oct 13, 2022
@github-actions github-actions bot added this to the v4.3 milestone Oct 13, 2022
@avelad avelad removed the status: working as intended The behavior is intended; this is not a bug label Oct 13, 2022
@koenoe
Copy link
Contributor

koenoe commented Oct 13, 2022

I'm actually having issues with this right now as well, but with absolute values. I've noticed this TODO in the code, so I'm looking if I can implement this in a PR. Could have a look at the problem @Robloche is having as well, or would it be better to keep this separate?

@Robloche
Copy link
Contributor Author

Robloche commented Oct 13, 2022

You could have a look but should you able to fix both issues, 2 PRs would be better, I guess.
I also intend to fix this issue myself but don't have enough time right now.

EDIT: And by the way, if you solve the bug I reported, I'll be grateful forever. ;)

@avelad avelad added the component: WebVTT The issue involves WebVTT subtitles specifically label Oct 31, 2022
@Robloche
Copy link
Contributor Author

Robloche commented Nov 10, 2022

To clarify, line:91%,end means that the cue box should have a top property set to 91% - <height of cue box>.

In fact, a simpler way ot fix it would be to replace:
style.bottom = cue.line + '%';
by:
style.bottom = (100 - cue.line) + '%';

@avelad avelad removed this from the v4.3 milestone Nov 10, 2022
Robloche pushed a commit to Robloche/shaka-player that referenced this issue Nov 10, 2022
…roject#4567)

As stated in the specifications at
https://w3c.github.io/webvtt/#webvtt-line-cue-setting
and
https://w3c.github.io/webvtt/#webvtt-cue-line-alignment
the "end" modifier in the line alignment directive means that the box
is positioned from the top of the screen but relatively to its bottom
edge. The previous code actually positioned the box from the bottom of
the screen.
@joeyparrish joeyparrish reopened this Nov 10, 2022
@joeyparrish joeyparrish added the priority: P1 Big impact or workaround impractical; resolve before feature release label Nov 10, 2022
@avelad avelad added this to the v4.3 milestone Nov 10, 2022
joeyparrish added a commit that referenced this issue Dec 8, 2022
…4682)

As per spectification,
[here](https://w3c.github.io/webvtt/#webvtt-line-cue-setting) and
[there](https://w3c.github.io/webvtt/#webvtt-cue-line-alignment), my
understanding is that a cue line with an optional alignment position
`end`, e.g. `line:91%,end`, should have its bottom edge at 91% from the
top of the screen.

But the current code places it at 91% from the bottom of the screen.

Fixes #4567

Co-authored-by: Rodolphe Breton <[email protected]>
Co-authored-by: Joey Parrish <[email protected]>
joeyparrish added a commit that referenced this issue Dec 8, 2022
…4682)

As per spectification,
[here](https://w3c.github.io/webvtt/#webvtt-line-cue-setting) and
[there](https://w3c.github.io/webvtt/#webvtt-cue-line-alignment), my
understanding is that a cue line with an optional alignment position
`end`, e.g. `line:91%,end`, should have its bottom edge at 91% from the
top of the screen.

But the current code places it at 91% from the bottom of the screen.

Fixes #4567

Co-authored-by: Rodolphe Breton <[email protected]>
Co-authored-by: Joey Parrish <[email protected]>
joeyparrish added a commit that referenced this issue Dec 8, 2022
…4682)

As per spectification,
[here](https://w3c.github.io/webvtt/#webvtt-line-cue-setting) and
[there](https://w3c.github.io/webvtt/#webvtt-cue-line-alignment), my
understanding is that a cue line with an optional alignment position
`end`, e.g. `line:91%,end`, should have its bottom edge at 91% from the
top of the screen.

But the current code places it at 91% from the bottom of the screen.

Fixes #4567

Co-authored-by: Rodolphe Breton <[email protected]>
Co-authored-by: Joey Parrish <[email protected]>
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jan 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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
Projects
None yet
Development

No branches or pull requests

4 participants