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

Feature request: transparent background (not just black) #6590

Closed
daT4v1s opened this issue Mar 29, 2019 · 19 comments
Closed

Feature request: transparent background (not just black) #6590

daT4v1s opened this issue Mar 29, 2019 · 19 comments

Comments

@daT4v1s
Copy link

daT4v1s commented Mar 29, 2019

example situations:

  • playing audio with subtitles .SRT .VTT .ASS (allow to use window as overlay) with
    opaque subtitles
    • with completely transparent or semi-transparent-black background
  • playing custom rendered/composited RGBA videos
    or any video with opacity/alpha channel (YV12+A)

(also nice if possible to make most of the window (non-OSD-GUI) click-through

@CounterPillow
Copy link
Contributor

CounterPillow commented Mar 29, 2019

playing custom rendered/composited RGBA videos
or any video with opacity/alpha channel (YV12+A)

Exists and is called --alpha=yes.

Looks like --background not being affected by the alpha component is an oversight and might be easy to fix.

@Akemi Akemi closed this as completed Sep 20, 2019
@daT4v1s
Copy link
Author

daT4v1s commented Nov 28, 2019

apparently that does not work/implemented in linux,
i've seen examples via wine apps that do true-transparency
thus transparency is possible in linux

@ghost
Copy link

ghost commented Nov 29, 2019

It's possible, but Mesa broke it. The mpv manpage even mentions the Mesa bug number.

@benjaminBrownlee
Copy link

I noticed that the referenced EGL Mesa bug (67676) is now resolved. Any update on this implementation? It still does not work on my machine.

@guidocella
Copy link
Contributor

It seems that the merge request that closed the bug was reverted and now https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2376 has to be merged.

@ghost
Copy link

ghost commented Aug 27, 2020

I can try to look at it once all affected components have made it to something I can use and install. Is there any distro which has these changes yet? (Obviously I won't go too much out of my way for this.)

@ghost
Copy link

ghost commented Aug 27, 2020

Also I think Mesa forgot to write the EGL_MESA_config_select_group specification.

@ghost
Copy link

ghost commented Aug 27, 2020

OK, after looking some, the things mentioned above were reverted in Mesa. So this still can't be fixed. Blame Mesa.

ghost pushed a commit that referenced this issue Aug 27, 2020
Transparent windows on X11/EGL/native Mesa GL didn't work for various
reasons. From what I remember, the current code did work with nvidia at
least. Mesa has made attempts to fix this, but they never really made it
in.

But it turns out you can make EGL/Mesa list the EGLConfigs that use X11
RGBA visuals, and context_x11egl.c contains code that explicitly selects
them if alpha is requested (see pick_xrgba_config()).

The reason EGL/Mesa did not list them (and thus breaking transparency)
is because we requested a EGL_ALPHA_SIZE != 0 if alpha is requested. But
the transparent EGLConfigs use EGL_ALPHA_SIZE == 0. That's because EGL
doesn't actually support the concept of transparent windows; the alpha
size parameter is something else (memory rendering without FBOs or
something, I don't care enough to look up the real reasons).

This still won't work on Wayland. Every EGL backend needs platform
specific code. (Good job, EGL, such an awesome platform independent
standard.)

Fixes: #6590
@ghost
Copy link

ghost commented Aug 27, 2020

It turns out that you can circumvent the mess with another (existing mess) - it's fixed now on X11.

@benjaminBrownlee
Copy link

Sweet, I guess I'll download the mpv-git AUR pkg and test it out. Thanks for your help!

@guidocella
Copy link
Contributor

Any chance of making the alpha component affect --background?

guidocella added a commit to guidocella/mpv that referenced this issue Dec 6, 2020
--alpha=yes doesn't affect only transparent videos and images, but also
the background. I spent time trying researching how to implement
transparent backgrounds and had no idea that they already worked at
least on Wayland.

Background transparency will work on X11 when
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2376 is
merged. It doesn't work on Windows. No idea about macOS. Either way,
this paragraph already says that it only works on certain environments
twice.

References mpv-player#6590
guidocella added a commit to guidocella/mpv that referenced this issue Dec 6, 2020
--alpha=yes doesn't affect only transparent videos and images, but also
the background. I spent time researching how to implement transparent
backgrounds and had no idea that they already worked at least on
Wayland.

Background transparency will work on X11 when
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2376 is
merged. It doesn't work on Windows. No idea about macOS. Either way,
this paragraph already says that it only works on certain environments
twice.

References mpv-player#6590
Dudemanguy pushed a commit that referenced this issue Dec 8, 2020
--alpha=yes doesn't affect only transparent videos and images, but also
the background. I spent time researching how to implement transparent
backgrounds and had no idea that they already worked at least on
Wayland.

Background transparency will work on X11 when
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2376 is
merged. It doesn't work on Windows. No idea about macOS. Either way,
this paragraph already says that it only works on certain environments
twice.

References #6590
Dudemanguy pushed a commit to Dudemanguy/mpv that referenced this issue May 18, 2021
Transparent windows on X11/EGL/native Mesa GL didn't work for various
reasons. From what I remember, the current code did work with nvidia at
least. Mesa has made attempts to fix this, but they never really made it
in.

But it turns out you can make EGL/Mesa list the EGLConfigs that use X11
RGBA visuals, and context_x11egl.c contains code that explicitly selects
them if alpha is requested (see pick_xrgba_config()).

The reason EGL/Mesa did not list them (and thus breaking transparency)
is because we requested a EGL_ALPHA_SIZE != 0 if alpha is requested. But
the transparent EGLConfigs use EGL_ALPHA_SIZE == 0. That's because EGL
doesn't actually support the concept of transparent windows; the alpha
size parameter is something else (memory rendering without FBOs or
something, I don't care enough to look up the real reasons).

This still won't work on Wayland. Every EGL backend needs platform
specific code. (Good job, EGL, such an awesome platform independent
standard.)

Fixes: mpv-player#6590
Dudemanguy pushed a commit to Dudemanguy/mpv that referenced this issue May 18, 2021
--alpha=yes doesn't affect only transparent videos and images, but also
the background. I spent time researching how to implement transparent
backgrounds and had no idea that they already worked at least on
Wayland.

Background transparency will work on X11 when
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2376 is
merged. It doesn't work on Windows. No idea about macOS. Either way,
this paragraph already says that it only works on certain environments
twice.

References mpv-player#6590
@SaphiraKai
Copy link

I'm still having issues with this on Linux with X11, playing an RGBA video with mpv --alpha=yes test.mov and mpv --alpha=yes --background=00000000 test.mov both yield a solid black background. And yes I do have a compositor running

@Dudemanguy
Copy link
Member

Dudemanguy commented Jun 21, 2022

That's because it's still broken in Mesa. The commit that originally closed this issue may have possibly worked at the time as some weird hack, but it definitely doesn't work right now.

@cipricus
Copy link

cipricus commented Jan 23, 2023

There is the option to add an opacity value before the 6-digit hex number. Here is a list with all the values:

100% — FF
99% — FC
98% — FA
97% — F7
96% — F5
95% — F2
94% — F0
93% — ED
92% — EB
91% — E8
90% — E6
89% — E3
88% — E0
87% — DE
86% — DB
85% — D9
84% — D6
83% — D4
82% — D1
81% — CF
80% — CC
79% — C9
78% — C7
77% — C4
76% — C2
75% — BF
74% — BD
73% — BA
72% — B8
71% — B5
70% — B3
69% — B0
68% — AD
67% — AB
66% — A8
65% — A6
64% — A3
63% — A1
62% — 9E
61% — 9C
60% — 99
59% — 96
58% — 94
57% — 91
56% — 8F
55% — 8C
54% — 8A
53% — 87
52% — 85
51% — 82
50% — 80
49% — 7D
48% — 7A
47% — 78
46% — 75
45% — 73
44% — 70
43% — 6E
42% — 6B
41% — 69
40% — 66
39% — 63
38% — 61
37% — 5E
36% — 5C
35% — 59
34% — 57
33% — 54
32% — 52
31% — 4F
30% — 4D
29% — 4A
28% — 47
27% — 45
26% — 42
25% — 40
24% — 3D
23% — 3B
22% — 38
21% — 36
20% — 33
19% — 30
18% — 2E
17% — 2B
16% — 29
15% — 26
14% — 24
13% — 21
12% — 1F
11% — 1C
10% — 1A
9% — 17
8% — 14
7% — 12
6% — 0F
5% — 0D
4% — 0A
3% — 08
2% — 05
1% — 03
0% — 00

(I have found about it here.)
So, to play mpv with a 80% opacity of a black subs background: mpv --sub-back-color=#CC000000 video.mp4

@iiiGerardoiii
Copy link

that's cool @cipricus , but I think this bug is about trying to achieve full transparency of the video itself, not the subtitles.

e.g. opening a .png image of a circle and the corners of the image are showing whatever is behind the window, instead of a checkerboard pattern.

@cipricus
Copy link

that's cool @cipricus , but I think this bug is about trying to achieve full transparency of the video itself, not the subtitles.

e.g. opening a .png image of a circle and the corners of the image are showing whatever is behind the window, instead of a checkerboard pattern.

Sorry, I must have misunderstood. Too eager to share !

@wick3dr0se
Copy link

wick3dr0se commented Mar 24, 2024

@iiiGerardoiii even though @cipricus misunderstood, a valid point was made.. Hex accepts opacity and that means it should work fine. And it does!

mpv FILE --background=#00000000 -- alpha=yes

Also the opacity is the last two, not the first

@digitalsignalperson
Copy link

thanks @wick3dr0se, confirmed here --background=#00000000 --alpha=yes working with a mpv wayland window and a .mov with transparency

@iiiGerardoiii
Copy link

@iiiGerardoiii even though @cipricus misunderstood, a valid point was made.. Hex accepts opacity and that means it should work fine. And it does!

mpv FILE --background=#00000000 -- alpha=yes

wtf @cipricus was right all along

I stand corrected.

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