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
RGB with alpha channel is always black in ffmpeg/ffplay #171
Comments
I think this is an issue with ffplay itself (I'm using a git build from June 2nd and can reproduce this on Windows 10). Initially I thought it might even be in SDL2, but using SDL2 through mpv's sdl vo displays bgra correctly (mpv's vo=gpu only displays the checkerboard for alpha-laden formats, which is a not-so-minor annoyance). You can see that ffmpeg itself is fine with it by bypassing ffplay:
Or if you've built said mpv against the patched FFmpeg, just opening the script directly like you would have with ffplay:
If you're passing it to mpv's gpu vo, use Although weirdly, if I import real video in through ffms2 and use It seems like VDub2's YUVA support for AviSynth+ (maybe in general?) is still a little finicky. YUVA444 doesn't work - it gives the error you described - but YUVA444P16 seems to be fine. |
Could it be that ffmpeg is one of the first AviSynth+ clients to ever care about the alpha plane? BlankClip(color=$FF, pixel_type="RGB32")
ConvertToPlanarRGBA()
alpha = "0"
Expr(last, "0", "0", "255", alpha, format="RGBAP8")
Info()
ShowFrameNumber(true) It seems that the alpha plane is zero-initialized by default. |
Also seems to do it in a much simpler way than using |
Zero initialized because color=$FF |
LOL! I feel so dumb. |
Obviously, the responsability of maintaining the wiki is not only yours. We should find together a way to make it more intuitive ( |
Yes, I found other places to fix it |
So, this should actually mean we need to fix colors_rgb.avsi and add the alpha values. Even using color=color_blue instead of the hex values still exhibited the problem described here. And, I'm not understanding how it's parsing the hex values. color=$FF produces blue. But the full hex for that should be $0000FF (as shown in colors_rgb.avsi). Is it just a quirk of how hex parsing works that omitted zeroes are inserted between the given values and the $ instead of after ($FF0000 produces red)? Is that due to endianness, or something else? Would this act differently if we were running on a big-endian platform (this is important for both ARM and potentially if we ever add PowerPC, as both of those can operate in either little or big endian, with ARM mostly little and PowerPC mostly big). Then to add alpha in, alpha is weird in that it's seemingly acting in reverse of what users might expect - values for the R-G-B channels run from 0 to 255, with zero being no strength and 255 being full strength. $000000 is thus black and $FFFFFF is white, because those channels are always visible. Alpha, on the other hand, is using it in terms of what alpha is, transparency. 0 is completely opaque (which makes it appear black in ffplay, but as the typical transparent checkerboard placeholder in mpv, arguably far more accurate than black is), 255 is completely transparent. I think user friendliness might require adding something like an alpha_opacity argument that flips this so that 0=transparent 1.0=opaque. Or implementing a standalone function (Opacity¹) that only controls the visibility of the individual channels and nothing else (as opposed to what Overlay, Layer, or the Show* functions do in manipulating channels). ¹whether this should also include derived functions for each channel - OpacityRed, OpacityAlpha - is another question. |
There are also the main docs. The wiki is currently more up-to-date than the docs are because everyone goes there, but since the [english] docs are now in ReStructuredText format, changes to those are simpler than editing HTML and can be submitted upstream in a normal pull request. |
To my mind, the Alpha channel does not work so differently from RGB: 0 is "I can't see anything" and 255 is "I can see". |
I would describe it the opposite way. Alpha is a visibility modifier. 0 makes all planes totally transparent (thus the checkerboard pattern) and 255 makes them visble (that is, opaque over the picture being composed underneath). This matches the description of Alpha in Wikipedia. So it seems like we should see Alpha as 'opacity' rather than 'transparency'. |
Then there is another historical fact: Colorbars RGB32 is using 0 for alpha channel. |
The following script:
Looks like this in VirtualDub2 (using AVS+ 3.6.0):
But it produces a black screen in ffplay:
I'm using ffmpeg 4.2.3 on linux, but with @qyot27's patches for Avisynth+ support (backported to Arch Linux's official ffmpeg package as of this morning).
I have tried with different bit depths and with packed/planar formats, and only RGB formats with an alpha plane seem affected.
I had difficulties testing YUVA. I wrote the following script which works in ffplay, but throws an error in VirtualDub2:
The text was updated successfully, but these errors were encountered: