mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.3k stars 2.9k forks source link

HDR not matching youtube #6072

Closed ggarra13 closed 5 years ago

ggarra13 commented 6 years ago

mpv version and platform

mpv 0.26.0-244-g71c25df5e6-dirty (C) 2000-2017 mpv/MPlayer/mplayer2 projects built on Fri Aug 10 10:51:25 -03 2018 ffmpeg library versions: libavutil 56.18.102 libavcodec 58.21.104 libavformat 58.17.101 libswscale 5.2.100 libavfilter 7.25.100 libswresample 3.2.100 ffmpeg version: N-91456-g0b2c14c797

Reproduction steps

mpv --tone-mapping linear Samsung\ Wonderland\ Demo.ts

Expected behavior

The movie should match the one in you-tube, which looks right. Neither too dark, nor too bright, nor saturated.

Actual behavior

The movie in mpv looks dark. When using the default tone-mapping, the movie looks oversaturated.

Log file

https://mega.nz/#!RtoWHIDJ!7NOsFsQ4fB3C4uDQSJeoYVxm0SxuUkAl6w10PdDP4Zk

Sample files

Movie file is available in youtube at:

https://www.youtube.com/watch?v=W9_36xuh2is https://4kmedia.org/ultra-hd-hdr-samsung-4k-demo-wonderland/

CounterPillow commented 6 years ago

mpv 0.26.0-244-g71c25df5e6-dirty (C) 2000-2017 mpv/MPlayer/mplayer2 projects

update mpv. There have been HDR changes since then. This isn't even a commit that exists in the repository, and the -dirty makes me think you use some out-of-tree changes too.

ggarra13 commented 6 years ago

I tried:

mpv 0.29.0-19-g6c2d6a3046 Copyright © 2000-2018 mpv/MPlayer/mplayer2 projects built on Tue Aug 14 13:20:59 -03 2018 ffmpeg library versions: libavutil 56.18.102 libavcodec 58.21.104 libavformat 58.17.101 libswscale 5.2.100 libavfilter 7.25.100 libswresample 3.2.100 ffmpeg version: N-91456-g0b2c14c797

and the result was worse. The image appears bright at the beginning and then goes dark after less than a second.

ggarra13 commented 6 years ago

Here's the updated log file:

https://0x0.st/sJQ5.txt

ggarra13 commented 6 years ago

El 14/08/18 a las 13:21, sfan5 escribió:

Closed #6072 https://github.com/mpv-player/mpv/issues/6072.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mpv-player/mpv/issues/6072#event-1788226936, or mute the thread https://github.com/notifications/unsubscribe-auth/AFyqC5EWl9uY4o1a2UPf7pwq5vuQH6fqks5uQvkkgaJpZM4V8hYt.

Please don't close this thread as I was unable to verify current HEAD works correctly. As a matter of fact, it seems to work worse.

-- Gonzalo Garramuño

wsldankers commented 6 years ago

Have you tried --no-hdr-compute-peak?

ggarra13 commented 6 years ago

El 16/08/18 a las 12:31, Wessel Dankers escribió:

Have you tried |--no-hdr-compute-peak|?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mpv-player/mpv/issues/6072#issuecomment-413586284, or mute the thread https://github.com/notifications/unsubscribe-auth/AFyqC9t13o9pfUJghsARA8eC9IpF_rTTks5uRZBMgaJpZM4V8hYt.

Thanks.  I was unaware of that option.  That makes it look much closer, but the darks are still a tad too dark.

-- Gonzalo Garramuño

aufkrawall commented 6 years ago

The displayed logo might have the highest brightness and thus confuse peak detection.

I assume @haasn is well aware of that. With my limited technical knowledge, I suppose there could be some kind of logo detection that ignores top brightness areas which don't exceed a certain length and width.

ggarra13 commented 6 years ago

El 16/08/2018 a las 16:25, aufkrawall escribió:

The displayed logo might have the highest brightness and thus confuse peak detection.

Yes, but that doesn't explain why you-tube has no problem with it.

I assume @haasn https://github.com/haasn is well aware of that. With my limited technical knowledge, I suppose there could be some kind of logo detection that ignores top brightness areas which are below a certain length and width.

Also the problem, imho, is not the peak detection but the black level.

-- Gonzalo Garramuño

Doofussy2 commented 6 years ago

Maybe try:

hdr-compute-peak=no tone-mapping=mobius

Looks pretty good

snapshot_16

haasn commented 6 years ago

You can also try tone-mapping=gamma, but I think hable is what youtube should more or less be using?

@ggarra13, can you please attach screenshots describing the problem for issues like this? Makes it easier for everybody involved to understand what you mean / what you expected.

ggarra13 commented 6 years ago

Here are a set of images from different parts of the video (the lower and darker ones are mpv): samsumg0 captura de pantalla de 2018-08-17 12-09-15

samsung2 captura de pantalla de 2018-08-17 12-00-55

The mpv images correspond to the setting hdr-compute-peak=no tone-mapping=mobius

Doofussy2 commented 6 years ago

I have to say, there is a huge difference between using hdr-compute-peak, and not using it.

With; hdr-compute-peak=no tone-mapping=gamma

mpv-shot0002

With; hdr-compute-peak=yes tone-mapping=gamma

mpv-shot0001

And here's difference between mobius and gamma when using hdr-compute-peak

Mobius

mpv-shot0001

Gamma

mpv-shot0002

ggarra13 commented 6 years ago

And here's how it should look like:

samsung0

Doofussy2 commented 6 years ago

How about this?

hdr-compute-peak=no tone-mapping=mobius target-trc=gamma2.8 target-peak=250

mpv-shot0004

sfan5 commented 6 years ago

That's not even close: https://diff.pics/0i6WeEtP5XK5/1

Notice the loss of detail in the snowy areas of the mountain. The cloud's red is also way too intense.

Doofussy2 commented 6 years ago

Yeah, I saw that. Nothing I tried, matched that shade of pink. It was either more vibrant or losing color.

aufkrawall commented 6 years ago

With --hdr-compute-peak=yes, the colors look more balanced in videos in which it works well in general.

Doofussy2 commented 6 years ago

I actually like how mpv tone maps, but I do find that in general, it's too dark. I've started using this config to improve that.

gpu-api=opengl opengl-pbo hdr-compute-peak=yes tone-mapping-desaturate=0.17 tone-mapping=gamma tone-mapping-param=1.8

I've left the mapping-param at it's default. At 2.2 I noticed that the colors are flattening out and there's visible loss of tone detail. I like it at default, but raising it to 2.0 should be ok. But I can't find a way to match what YouTube is putting out.

Doofussy2 commented 6 years ago

To illustrate what I mean by 'too dark', here is a screenshot of using my config, compared to just using hdr-compute-peak. These are from the movie, Lucy.

With only hdr-compute-peak

mpv-shot0004

And with my config

mpv-shot0008

ggarra13 commented 6 years ago

For what is worth, VLC seems to play the Samsung Demo with colors matching youtube much more closely.

Doofussy2 commented 6 years ago

I have a feeling YouTube is just 8 bit. So it's going to look different.

ggarra13 commented 6 years ago

El 23/08/18 a las 18:40, Doofussy2 escribió:

I have a feeling YouTube is just 8 bit. So it's going to look different.

No, it isn't.  I downloaded the sample we are trying with youtube-dl.  The source is the youtube video.

-- Gonzalo Garramuño

Doofussy2 commented 6 years ago

Right, but when playing, it may be tone mapped to 8 bit?

haasn commented 6 years ago

For what is worth, VLC seems to play the Samsung Demo with colors matching youtube much more closely.

On what platform?

haasn commented 6 years ago

It's possible that us targetting a frame average brightness of 50 cd/m² under-darkens frames which have a mixture of bright and mild stimuli, such as the last screenshot posted. Maybe we should use the root mean square instead of the mean frame brightness, or something?

haasn commented 6 years ago

On what platform?

Actually never mind, I realize from your log that you are using Linux. If you are using VLC >4, the only tone mapping VLC does on Linux is based on libplacebo, which uses pretty much the same algorithm as recent mpv - the only difference being that VLC has HDR peak detection disabled (out of necessity). Apart from that, the default settings are the same as mpv:

    add_integer("tone-mapping", PL_TONE_MAPPING_HABLE, \
                TONEMAPPING_TEXT, TONEMAPPING_LONGTEXT, false) \
            change_integer_list(tone_values, tone_text) \
    add_float("tone-mapping-param", pl_color_map_default_params.tone_mapping_param, \
              TONEMAP_PARAM_TEXT, TONEMAP_PARAM_LONGTEXT, true) \
    add_float("tone-mapping-desat", pl_color_map_default_params.tone_mapping_desaturate, \
              TONEMAP_DESAT_TEXT, TONEMAP_DESAT_LONGTEXT, false) \

which references the default values here:

const struct pl_color_map_params pl_color_map_default_params = {
    .intent                  = PL_INTENT_RELATIVE_COLORIMETRIC,
    .tone_mapping_algo       = PL_TONE_MAPPING_HABLE,
    .tone_mapping_desaturate = 0.5,
    .peak_detect_frames      = 63,
    .scene_threshold         = 0.2,
};

This is the same as the mpv defaults (when peak detection is disabled):

    .tone_mapping = TONE_MAPPING_HABLE,
    .tone_mapping_param = NAN,
    .tone_mapping_desat = 0.5,

If you're using VLC <4, there's no HDR tone mapping being done at all on Linux.

ggarra13 commented 6 years ago

hassn,

You are right on almost everything. I was able to match the output of youtube with hable, nan, desat 0.5 (the defaults when turning off peak detection). Not sure why I could not map it before (maybe because I was compiling my own mpv). vlc comes with tone-mapping since v3 (Ubuntu release), it seems, as this version already does tone mapping (and in the source has references to libplacebo):

$ vlc --version VLC media player 3.0.3 Vetinari (revision 3.0.3-1-0-gc2bb759264) Versión de VLC 3.0.3 Vetinari (3.0.3-1-0-gc2bb759264) Compilado por buildd en lgw01-amd64-040.buildd (Jul 18 2018 14:06:05) Compilador: gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)

haasn commented 6 years ago

Sorry, I mean VLC 3, not 4. You are right.

Doofussy2 commented 6 years ago

But on Windows 10, it doesn't match

@ggarra13's screenshot

44302902-f9c05f00-a308-11e8-80f2

And the screenshot I just took with:

hdr-compute-peak=no tone-mapping-desaturate=0.5 tone-mapping=hable tone-mapping-param=NAN

mpv-shot0001

Portable mpv log.txt

ggarra13 commented 6 years ago

I was wrong. On Linux it still does not match. There's a difference in brightness and in saturation with the default values. The saturation can be compensated with the tone-mapping control, but the brightness can't.

aufkrawall commented 6 years ago

The default setting with compute-peak enabled really tends to way too dark images. That's from the LG chess demo which doesn't have any logos shown: https://abload.de/img/mpv-shot0001sditt.jpg https://abload.de/img/mpv-shot0002xefpc.jpg

Can be also observed in the Samsung "chasing the light" demo before the logo appears: https://abload.de/img/mpv-shot0003i6eap.jpg

However, the color reproduction is really nice with with compute-peak: https://abload.de/img/mpv-shot0004ppejy.jpg

I guess there is a lot of potential in it once it works more reliably with various sources in general. Btw. also great that it does work with D3D11 now.

haasn commented 6 years ago

That LG chess screenshot is indeed way darker than it should be. Are you sure the version of the clip you have has HDR metadata attached? (Failure to include any will result in mpv defaulting to 10,000 cd/m² peak, which results in a very dark image)

In general, it might be a better idea to use e.g. tone-mapping=mobius when peak detection is not enabled. But YMMV.

I haven't had time to look at all of the results and track down improvements that could be made. But the one thing that caught my attention is that you seem to be suggesting that VLC on Linux has a different result from mpv with peak detection disabled? Because this should really not be the case, and might point to an actual bug.

aufkrawall commented 6 years ago

Regarding the LG chess demo: I noticed that --hdr-peak-detection=yes suddenly gets too dark when the scene with the camera close to the woman's face appears. This can be also provoked by jumping to that second with shift + right arrow key.

Second 13: https://abload.de/img/screenshot_20180826_1k1cpe.png

Second 14: https://abload.de/img/screenshot_20180826_1nid63.png

Regarding to MediaInfo, the file is correctly flagged with Mastering display luminance: min: 0.05 cd/m², max: 1000 cd/m² At also looks "correct" with --hdr-peak-detection=no and VLC.

Again regarding better colors with --hdr-peak-detection=yes: =yes: https://abload.de/img/mpv-shot0002dqemm.jpg

=no: https://abload.de/img/mpv-shot00018mcs1.jpg

Something's fundamentally better with =yes.

ggarra13 commented 6 years ago

H

I haven't had time to look at all of the results and track down improvements that could be made. But the one thing that caught my attention is that you seem to be suggesting that VLC uon Linux has a different result from mpv with peak detection disabled? Because this should really not be the case, and might point to an actual bug.

No. Vlc matches mpv. I was wrong. Sorry. There's a difference in brightness and saturation. The saturation can be compensated but the brightness can't.

ggarra13 commented 6 years ago

Talking about mpv, is there a way to get the source code to the GL shader mpv is using. I would like to feed it into my viewer and play with the contrast/brightness.

ggarra13 commented 6 years ago

Never mind. I found that doing -v -v -v outputs the shader source code.

aufkrawall commented 5 years ago

@haasn Did you see my post regarding broken --hdr-peak-detection=yes above? It's still getting suddenly dark after second 13.

haasn commented 5 years ago

@aufkrawall I saw, but without looking at the source in particular I'm not sure what would be a good way of working around it. In general it seems like a zoom in on a bright object in a dark room would be awful for this style of dynamic tone mapping.

Do you know how other dynamic tone mapping algorithms handle it, or do you have any suggestions of how the current approach could be improved?

Doofussy2 commented 5 years ago

For what it's worth, I turn hdr-compute-peak off, now. Some scenes get too dark. Here is a scene from Justice League at 1:15:35

with hdr-compute-peak mpv-shot0001

without hdr-compute-peak mpv-shot0002

Doofussy2 commented 5 years ago

I should also add that I set tone-mapping-desaturate=0.0

Doofussy2 commented 5 years ago

I think this now looks correct, with @haasn's new adjustments

mpv-shot0001

https://github.com/mpv-player/mpv/issues/6405#issuecomment-453338988