mpv-player / mpv

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

Color management issue #3120

Closed ghost closed 8 years ago

ghost commented 8 years ago

MPV doesn't seem to like my display profile. I have a blue tint when using color management (icc-profile-auto). It's apparent on dark colors and grays. I've already tried changing the size to 256x256x256 and the four color rendering intents.

My ICC profile was made using DisplayCAL. It's a XYZ Lut + Matrix profile. The settings that were used when making the profile are whitepoint: 6500K and tone curve: gamma 2.2 (The default "Office & Web" preset).

The image looks neutral on my monitor in Photoshop, XnViewMP and MPC-HC + MadVR (using a 3DLUT calibration file made on DisplayCAL). But it's completely blue in MPV.

Here I'm attaching the following files:

  1. The source image
  2. The ICC profile used
  3. A log of mpv -v
  4. The actual result
  5. The expected result (Taken from XnViewMP with color profile being applied. It's being treated as sRGB, as it's used by default when there is no embedded profile present)

1 source

  1. Github won't let me upload the icc profile, so here it is: https://my.mixtape.moe/btujkb.icm

[cplayer] Command line options: '-v'
[cplayer] mpv 0.17.0-git-190578b (C) 2000-2016 mpv/MPlayer/mplayer2 projects
[cplayer]  built on Mon Apr 11 19:16:14 CEST 2016
[cplayer] ffmpeg library versions:
[cplayer]    libavutil       55.20.100
[cplayer]    libavcodec      57.34.100
[cplayer]    libavformat     57.33.100
[cplayer]    libswscale      4.1.100
[cplayer]    libavfilter     6.41.100
[cplayer]    libswresample   2.0.101
[cplayer] ffmpeg version: N-79342-g95f8a9e
[cplayer] 
[cplayer] Configuration: /home/lachs0r/mingw-w64-cmake/buildroot/build64/packages/mpv-prefix/src/mpv/waf configure --enable-static-build --enable-pdf-build --disable-manpage-build --enable-libmpv-shared --enable-gpl3 --enable-encoding --disable-egl-angle --enable-lua --enable-libarchive --enable-libass --enable-libbluray --enable-dvdread --enable-dvdnav --enable-uchardet --enable-rubberband --enable-lcms2 --prefix=/home/lachs0r/mingw-w64-cmake/buildroot/build64/prefix/mingw
[cplayer] List of enabled features: asm atomics av-avpacket-int64-duration av-new-pixdesc av-pix-fmt-mmal av-subtitle-nopict av-version-info avcodec-chroma-pos-api avcodec-has-codecpar avcodec-profile-name avframe-metadata avframe-skip-samples build-date c11-tls cplayer d3d-hwaccel d3d11va-hwaccel debug-build direct3d dlopen dos-paths dvdnav dvdread dxva2-hwaccel encoding gl gl-dxinterop gl-win32 glob-win32-replacement gpl3 iconv jpeg lcms2 libarchive libass libass-osd libav libavdevice libavfilter libbluray libm libmpv-shared libswresample lua mingw noexecstack optimize posix-or-mingw resampler rubberband sse4-intrinsics static-build stdatomic subprocess tv uchardet wasapi win32 win32-internal-pthreads zlib
[global] config path: '' -> 'C:\Users\Omelette\AppData\Roaming/mpv'
[global] config path: 'mpv.conf' -> 'C:\Users\Omelette\AppData\Roaming/mpv/mpv.conf'
[global] config path: 'config' -/-> 'C:\Users\Omelette\AppData\Roaming/mpv/config'
[global] config path: 'mpv.conf' -/-> 'C:/Users/Omelette/Desktop/New folder/mpv.conf'
[global] config path: 'config' -/-> 'C:/Users/Omelette/Desktop/New folder/config'
[global] config path: 'mpv.conf' -/-> 'C:/Users/Omelette/Desktop/New folder/mpv/mpv.conf'
[global] config path: 'config' -/-> 'C:/Users/Omelette/Desktop/New folder/mpv/config'
[cplayer] Reading config file C:\Users\Omelette\AppData\Roaming/mpv/mpv.conf
[cplayer] Setting option 'vo' = 'opengl-hq:interpolation:backend=dxinterop:blend-subtitles:3dlut-size=256x256x256:icc-profile-auto' (flags = 4)
[cplayer] Setting option 'video-sync' = 'display-resample' (flags = 4)
[cplayer] Setting option 'hwdec' = 'no' (flags = 4)
[cplayer] Setting option 'v' = '' (flags = 8)
[cplayer] mpv 0.17.0-git-190578b (C) 2000-2016 mpv/MPlayer/mplayer2 projects
[cplayer]  built on Mon Apr 11 19:16:14 CEST 2016
[cplayer] ffmpeg library versions:
[cplayer]    libavutil       55.20.100
[cplayer]    libavcodec      57.34.100
[cplayer]    libavformat     57.33.100
[cplayer]    libswscale      4.1.100
[cplayer]    libavfilter     6.41.100
[cplayer]    libswresample   2.0.101
[cplayer] ffmpeg version: N-79342-g95f8a9e
[cplayer] 
[cplayer] Usage:   mpv [options] [url|path/]filename
[cplayer] 
[cplayer] Basic options:
[cplayer]  --start=<time>    seek to given (percent, seconds, or hh:mm:ss) position
[cplayer]  --no-audio        do not play sound
[cplayer]  --no-video        do not play video
[cplayer]  --fs              fullscreen playback
[cplayer]  --sub-file=<file> specify subtitle file to use
[cplayer]  --playlist=<file> specify playlist file
[cplayer] 
[cplayer]  --list-options    list all mpv options
[cplayer] 

4 ctrl s_screenshot_on_mpv 5 calibration_applied_on_xnviewmp

Hrxn commented 8 years ago

Color management, our favorite topic here :smile:

First of all, I think it's easier if you post the output of mpv -v directly into a comment here.

What happens if you load your 3DLUT file in mpv via icc-cache-dir=<dirname>?

And maybe post a full log of mpv with the opened file, i.e. --log-file=<path> <file>

Edit: Oh, and for the record. The difference in the sample images is clearly visible, even on crappy laptop screen ;)

ghost commented 8 years ago

First of all, I think it's easier if you post the output of mpv -v directly into a comment here.

Done.

What happens if you load your 3DLUT file in mpv via icc-cache-dir=?

I don't think I can load the MadVR 3DLUT using that command. Or at least I don't know how to make it work. It creates a new folder in the source path with a random-name generated file.

And maybe post a full log of mpv with the opened file, i.e. --log-file=

Here you are (I'm afraid it's too long to put it on a post): a.txt

jeeb commented 8 years ago

Please use three symbols, break a line, post your stuff and then do another set of three symbols on a final line. That would be much more readable for such type of content (the preview should show you how much better it looks). Thank you.

(and since it wasn't obvious, I meant the quoted content)

edit: or actually you might just not be finishing the quoted part of the message you're replying to.

ghost commented 8 years ago

What happens if you load your 3DLUT file in mpv via icc-cache-dir=?

That won't work, it requires some sort of header which you can't easily make up.

haasn commented 8 years ago

That won't work, it requires some sort of header which you can't easily make up.

It also requires a specific format and the right filename.

As for the OP issue, I can't reproduce it on my end. Using the latest master (f99e48a), I am running this:

mpv --fullscreen=no --geometry 1920x1200 -vo opengl-hq:dither-depth=8:icc-profile=/mem/btujkb.icm:3dlut-size=256x256x256 /mem/46418e00-1538-11e6-91b2-ce802f3b8ae4.jpg

Taking a raw screendump of this using import -depth 8 filename.png gives me the following PNG output:

mpv master

Inspecting the color values using a color picker (in krita, specifically); any deviations from the original neutral tones seems to be due to a combination of rounding error and dithering, both which are unavoidable. (Your reference image also has these off-by-ones)

Edit: I did not tag the result of this image, so the gamma will look wrong in browsers like firefox that do color management. When comparing, remember to either inspect pixel values directly or view them with CMS turned off.

Also, for some reason your “reference” result seems to have the black levels boosted by an insane degree. I can't tell you why that's the case, but it doesn't seem to be a part of the original image.

But either way, this was about the white balance specifically.

Edit 2: Just to be sure, I re-uploaded a stripped, tagged version of the image.

mpv master stripped+tagged

This version should now look similar to the original in browsers and other programs that do color management.

haasn commented 8 years ago

Also, your log indicates you are using mpv version 190578b which does not seem to be a valid commit I can locate anywhere. What's going on there?

ghost commented 8 years ago

Also, your log indicates you are using mpv version 190578b which does not seem to be a valid commit I can locate anywhere. What's going on there?

I'm using the latest 64-bit build from here: https://mpv.srsfckn.biz/

Edit 1: I've just tried running exactly the same as you (I renamed the picture and the profile to "a" and put them in the same folder):

mpv --fullscreen=no --geometry 1920x1200 -vo opengl-hq:dither-depth=8:icc-profile=a.icm:3dlut-size=256x256x256 a.jpg

And I'm still having the same blue tint.

Edit 2: And yes, the second image that you have posted is very similar to the one that I see when I open the source on a color-managed application.

haasn commented 8 years ago

Okay. For the reference, the only relevant difference since then in current master is the enabling of black point compensation, which doesn't seem to have made any effect here either way.

ghost commented 8 years ago

I'd like to add that the gamma differences between the source image and the expected result might be caused because XnViewMP is configured to treat images without embedded profile as sRGB.

haasn commented 8 years ago

I'd like to add that the gamma differences between the source image and the expected result might be caused because XnViewMP is configured to treat images without embedded profile as sRGB.

mpv is configured to treat all RGB images as sRGB regardless of any embedded profiles or not. (Unless you override it manually or FFmpeg somehow inexplicably provides colorspace tags for these images)

ghost commented 8 years ago

Edit 1: I've fixed some black crush and yellow tint problems by using icc-intent=0, but other images still look bluish.

Edit 2: If I open a bluish image in Photoshop and save it to png, it looks good on MPV. But if I save it to jpg again, it still looks bad. MP4 video files have the same problem, but I didn't see any png with the bluish tint. PNG and GIF files look exactly as expected.

haasn commented 8 years ago

So it only happens with YUV files and not RGB files?

What if you add `--vf=format=gamma=srgb?

ghost commented 8 years ago

I'm not sure about which files use YUV.

What if you add `--vf=format=gamma=srgb?

Using this works on both JPG and MP4 files, it fixes the problem This is the result: mpv-shot0001

haasn commented 8 years ago

@TallsFalls What if you use --vf=format=gamma=bt.1886 on the RGB files?

ghost commented 8 years ago

@haasn If I use bt.1886 the blue tint strikes again. I'd like to add that the blue tint problem also happens in my laptop, which is also calibrated with DisplayCAL.

haasn commented 8 years ago

Well, I can't reproduce it even with that option. Are we using different versions of LittleCMS and mpv, perhaps?

Can you try building the latest version of both and testing again?

ghost commented 8 years ago

I'm afraid I'm too dumb to do that. I'm trying to follow the "Native compilation with MSYS2" guide, but I'm having the error "Program ['gcc.exe'] is not executable"

Hrxn commented 8 years ago

Did you use a fresh installation of MSYS2?

ghost commented 8 years ago

Yes.

Hrxn commented 8 years ago

Um, okay. At which step does this error appear? Installing all the dependencies did finish successfully?

ghost commented 8 years ago

All the dependencies finished successfully. This happens at ./waf configure CC=gcc.exe --check-c-compiler=gcc --prefix=/mingw64

Hrxn commented 8 years ago

Well, I've never used waf personally, but Windows itself should not be the problem.

The syntax with ./ is a bit unusual.. I mean this should still work, theoretically. What happens when you just run waf from the /mpv directory?

ghost commented 8 years ago

Edit: My bad, I was skipping this step: Start a MinGW-w64 shell (mingw64_shell.bat). Note that this is different from the MSYS2 shell that is started from the final installation dialog.

@haasn On my built MPV I don't have any problem with color management. There are still small differences between MPV and Photoshop / XnViewMP, but now they are almost imperceptible.

haasn commented 8 years ago

cc @lachs0r

mia-0 commented 8 years ago

Still a problem? My builds use LCMS git master.

ghost commented 8 years ago

@lachs0r I don't have this problem since a long time ago.