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

feat(webvtt): webvtt colors output #4954

Merged
merged 5 commits into from
Feb 3, 2023
Merged

feat(webvtt): webvtt colors output #4954

merged 5 commits into from
Feb 3, 2023

Conversation

friday
Copy link
Contributor

@friday friday commented Jan 31, 2023

Adds color support for SimpleTextDisplayer and WebVttGenerator (only one place to fix both now thanks to #4941).

It's limited to the 8 colors classes supported by the WebVTT specification, and also works with their 3 or 6-digit hex variants (if the stream has TTML subtitles).

It does not support rgb, rgba or any colors other than these 8.

Fixes #4545

No need to perform the extra operations that only applies for real
payloads
reduceRight doesn't add any significance over just reduce, but need it for the output order to stay the same as before to pass current tests.
Fixes #4545

Will cover all valid color classes for webvtt cues, as well as
classes that are not valid webvtt class names, but are valid class names

Will exclude hex colors, rgb, rgba etc that could come from a ttml
input.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2023

Incremental code coverage: 98.77%

@avelad avelad self-requested a review February 1, 2023 05:55
@avelad avelad added type: enhancement New feature or request priority: P2 Smaller impact or easy workaround component: WebVTT The issue involves WebVTT subtitles specifically labels Feb 1, 2023
@avelad avelad added this to the v4.4 milestone Feb 1, 2023
@avelad
Copy link
Collaborator

avelad commented Feb 1, 2023

@friday I'll add some minor changes to support more TTML colors (eg), and I'll also try to add some test with your permission.

@friday
Copy link
Contributor Author

friday commented Feb 1, 2023

@friday I'll add some minor changes to support more TTML colors (eg), and I'll also try to add some test with your permission.

Appreciated 👍

@avelad
Copy link
Collaborator

avelad commented Feb 1, 2023

@friday I have already added the changes, in case you want to review. I think it would also be good if you updated the description of the PR.

@avelad
Copy link
Collaborator

avelad commented Feb 1, 2023

@joeyparrish , I think the web_vtt_layout_integration.js tests should include some of these cases, what do you think?

Eg:
<c.red.bg_magenta>Test</c>

Copy link
Contributor Author

@friday friday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved @avelad 👍 (and updated description)

This does mean that other colors like orange, pink etc would be removed, which may or may not be a good thing. I like the clarity of drawing the line at these 8 colors (and their hex variants) though, and nice to lose the regex 👍

About TTML color formats, I never used them myself, so I don't know what is more common, but from what I read I believe they can be named colors, 6 or 8 digit hex (for alpha channel), rgb or rgba. I wouldn't be surprised if 3 digit hex was also commonly supported and used though.

Supporting rgb(a) is harder to parse efficiently since they're not white-space sensitive, and it would add more complexity and regex.

@avelad avelad merged commit ed7a736 into shaka-project:main Feb 3, 2023
@friday friday deleted the feat/webvtt-colors-output branch February 6, 2023 11:15
@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: WebVTT The issue involves WebVTT subtitles specifically priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: enhancement New feature or request
2 participants