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

Transparency in the output #16

Open
eladalon1983 opened this issue Jul 17, 2023 · 2 comments
Open

Transparency in the output #16

eladalon1983 opened this issue Jul 17, 2023 · 2 comments

Comments

@eladalon1983
Copy link
Contributor

eladalon1983 commented Jul 17, 2023

When capturing an entire tab, all pixels are completely opaque. But what when capturing an element? Some of its pixels could be partially or fully transparent.

If getDisplayMedia() outputs a transparency-capable format, there is no issue. This is the ideal case, and should be the long-term goal of any implementation. The rest of this issue deals with a fallback in the short- and medium-term.

The specification has several options for what it could mandate if gDM cannot return a transparency-capable format, including:

  1. Remove the alpha-value of all pixels, making them opaque.
  2. Blend transparent pixels with an arbitrary value (likely white, possibly black).
  3. Blend transparent pixels with a value of the app's choosing.
  4. Blend transparent pixels with the target element's own background-color, with the alpha channel cleared out.
  5. Blend transparent pixels with the body's own color.

I think the best would be:

  • Long-term, all implementations should return a transparency-capable format (if the application requests it).
  • Medium-term, we could consider option 3, though arguably it'd become throw-away work once an implementation supports a transparency-capable format.
  • Short-term, it should be easy and mostly sufficient to specify option 1.
@khushalsagar
Copy link

If getDisplayMedia() outputs a transparency-capable format, there is no issue.

What are the cases where this won't happen. If the format in which the video is being encoded is in control of the site, can we force them to use a format which supports transparency if the stream is for element capture?

@eladalon1983
Copy link
Contributor Author

I am not aware of a way for the app to control the video format in the MediaStreamTrack. (Different story when it's written to a file or sent over the network.)

As of the time of writing, the getDisplayMedia spec does not mandate that a transparency-capable format be used in the MST returned. We might have to accommodate the possibility of a browser implementing getDisplayMedia and Element Capture, while using an alpha-incapable video format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants