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

Movies with Alpha are displayed Premultiplied with black #4983

Closed
NNois opened this Issue Oct 13, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@NNois

NNois commented Oct 13, 2017

Hi, we have issues with transparent videos withe well know premul/unpremult stuff
I've put some demo files together at the bottom

what_we_should_see
what_we_should_see

what we actually see in mpv
what_we_see_in_mpv_171013

why ? because the decoder multiply the rvb channel with the alpha channel, then display it so you end up with a premultiplied image "bug"

If source is premultiplied with black
the rvb is
checkalpha_ qtrle_premultiplied_rvb_screenshot png
the alpha is
alpha_channel

If source is unpremultiplied
the rvb is
rvb_channel
the alpha is
alpha_channel

So what mpv should do is
if premultiplied -> unpremultiply before compositing it to the checker grid
if unpremultiplied -> do nothing and comp it to the checker grid

This is tricky stuff but for example quicktime file with a codec compatible with an alpha channel do contain some bit about the source mode if it's a premult on or not. Some image file format too implies it, for example pngs file are always unpremultiplied.

Maybe a first step for MPV should be to do nothing, so at least unpremultiplied stuff are ok to play without bug

PS: maybe you need more media format like a prores4444 file ? please let me know

mpv version latest

Sample files

https://drive.google.com/drive/folders/0B1K5Lo1-_y9QTXNNYWFNYzFwZkE?usp=sharing

@NNois NNois changed the title from Movie with Alpha are displayed Premultiplied with black to Movies with Alpha are displayed Premultiplied with black Oct 13, 2017

@wm4

This comment has been minimized.

Contributor

wm4 commented Oct 13, 2017

FFmpeg thinks all alpha is unpremultiplied.

Do you know whether the alpha mode is defined for mov? Is there a flag in the file headers?

@NNois

This comment has been minimized.

NNois commented Oct 15, 2017

Hi,
FFmpeg is right I think ;-) So at least we should display correctly unpremultiplied movies in MPV. Please find an unpremultiplied movie in the files previously linked.

Yes there is some sort of alpha mode flag in the header because Graphics Apps like Adobe After effect switch to the right mode with mov files. But I don't know where to look exactly but ffmprobe don't see any differences between the two mov files provided...

@wm4 wm4 closed this in d3c0227 Oct 19, 2017

@wm4

This comment has been minimized.

Contributor

wm4 commented Oct 19, 2017

Not sure if it's correct now.

With boxdumper I can't see any difference between the premultiplied and unpremultiplied files, except creation_time and modification_time.

@NNois

This comment has been minimized.

NNois commented Oct 26, 2017

I can confirm it's fixed for unpremultiplied files ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment