ilia3101 / MLV-App

All in one MLV processing app.
https://mlv.app/
GNU General Public License v3.0
274 stars 30 forks source link

Add color management on viewer #273

Closed AndrewKeYanzhe closed 11 months ago

AndrewKeYanzhe commented 11 months ago

MLV-App doesn't appear to support color management in Windows and macOS.

I have attached a macOS screenshot: I used a test icc profile that turns colors to green/purple, and MLV-App is unaffected. Would it be possible to use Apple's system color management APIs? The UI canvas can be set to sRGB and video preview can be set to sRGB / rec709 depending on the presets. The system APIs should be quite performant.

My Windows system is Windows 10 with icc profile installed in Windows Color Management. In this case, color management will need to be implemented by the app.

Thanks!

Screenshot 2023-08-15 at 10 59 00 PM

ilia3101 commented 11 months ago

More details needed, can't reproduce:

https://github.com/ilia3101/MLV-App/assets/23642861/1a1750cb-112d-4b10-b6d2-c0ae7674e04d

Could it be a weird test profile? Weird build? Maybe an apple silicon build issue?

Sorry, no chance of colour management on windows. It requires lots of effort and still works like shit. Maybe windows 11 does something. Don't know.

AndrewKeYanzhe commented 11 months ago

I tried other color profiles like ACES CG Linear etc, and system UI will adjust accordingly but MLV-App does not apply the color profile.

I am using the M1 Macbook Air on macOS Ventura 13.4.1

What system are you using?

ilia3101 commented 11 months ago

Old 2015 MPB with monterey (also used Ventura 13.3.1 on this machine until just a few days ago, but too many problems).

What happens if you try running the intel build?

masc4ii commented 11 months ago

Tried on Mavericks, High Sierra and BigSur (Intel + Apple Silicon). 4x working, like Ilia showed. Qt seems not to support this for Windows. MLVApp viewer code is identical for all OS. So you could ask Qt for better support. Maybe they implement it for newer versions.

ilia3101 commented 11 months ago

Really weird !

AndrewKeYanzhe commented 11 months ago

I did another test using the Intel build on my M1 Macbook Air, and color management works.

I also recorded a slow motion video of the Apple silicon build, and you can see that color management works for a split second (1-2 frames?) before it reverts to being non color managed.

https://github.com/ilia3101/MLV-App/assets/22613058/d491125d-59d5-4a0d-9987-5793ff9fea45

masc4ii commented 11 months ago

Hm... Looks like a problem with Ventura then. On BigSur this doesn't happen, not on Intel and not on ARM architecture. At least I can't reproduce.

ilia3101 commented 11 months ago

I did another test using the Intel build on my M1 Macbook Air, and color management works.

How much worse is the performance compared to the ARM version? I would recomming using that I guess.

Are you able to compile MLV App from source? See if newer Qt fixes this. Otherwise you just have to wait for the next release and hope it improves.

Hm... Looks like a problem with Ventura then.

Only with the apple silicon build though. Weird.

masc4ii commented 11 months ago

How much worse is the performance compared to the ARM version?

Around 2.5x

I would recomming using that I guess.

Only with the apple silicon build though. Weird.

ARM version works without this issue here on M1.

AndrewKeYanzhe commented 11 months ago

Hm... Looks like a problem with Ventura then. On BigSur this doesn't happen, not on Intel and not on ARM architecture. At least I can't reproduce.

Which version of Qt are you using on your Apple silicon build?

I am using the official builds

The Telegram desktop app seems to suffer from this same issue on Ventura.

Telegram Desktop is oversaturated on macOs Ventura

Qt draws everything in sRGB while not telling about this to the system by default as the conversion is expensive for raster-based surfaces (they had this by default in early 5.x, but then reverted). https://github.com/telegramdesktop/tdesktop/issues/26166#issuecomment-1505091292

AndrewKeYanzhe commented 11 months ago

I tested the official Apple silicon build (Qt 5.15.3) on macOS Big Sur 11.7.9, M1 MacBook Air and color management is still not working. I suspect the issue is with the Qt version, and not macOS version.

Screenshot 2023-08-20 at 4 25 38 PM

masc4ii commented 11 months ago

Here it works on all my Macs with Qt 5.7.0 - latest Qt 6.5.2 the same way and exactly as Ilia showed. However... if Qt or macOS or your Macs or whatever. No idea how to help you here. There is nothing we could do. At least I have no idea. I don't see any bug we could solve.

AndrewKeYanzhe commented 11 months ago

Here it works on all my Macs with Qt 5.7.0 - latest Qt 6.5.2 the same way and exactly as Ilia showed. However... if Qt or macOS or your Macs or whatever. No idea how to help you here. There is nothing we could do. At least I have no idea. I don't see any bug we could solve.

Is it possible for you to share your Apple silicon builds using Qt 5.7.0 and Qt 6.5.2? Thanks for the help!

masc4ii commented 11 months ago

Qt5.7.0 is for Intel only. The official release uses it. The official ARM64 version uses Qt5.15.3, I have another test version using Qt5.15.10. If this one starts at all on your system (never checked this version on another than my mac), there shouldn't be any difference for the viewer (nothing changed since years). The version using Qt6.5.2 currently works on my other mac only atm, I had no success yet doing the deployment without error.

Here the ARM64 Qt5.15.10 version: https://www.dropbox.com/scl/fi/fu5x1g3jgrqkqb3n681ir/MLV-App-1.15rc.zip?rlkey=e5gauoglmjxylyktnm5tfng2m&dl=0

AndrewKeYanzhe commented 11 months ago

I can open the ARM64 Qt5.15.10 version after running xattr -cr <mlv_app_path>

I tried this build on Big Sur and Ventura, M1 Macbook Air, and color management is still not working. When I switch color profiles in system settings, MLV-App looks unchanged (sRGB oversaturated to P3 on my screen).

Perhaps you can share the Qt 6.5.2 build too? Maybe xattr -cr <mlv_app_path> will allow the app to run on a different system.

masc4ii commented 11 months ago

That was to be expected, that nothing changes. Why should it?

My Qt6 build currently won't run at all on any other than mine system - it has no libraries in the app archive. Sorry. You must compile on your own system. But I don't expect any change here too. It still won't change anything on your system. Whyever. It has nothing to do with Apple Silicon build - topic name is wrong. It seems all builds are doing exactly the same. If someone has time: try to integrate another multiplatform color management library on viewer window and bypass (if possible) whatever Qt does.

Maybe this thing can change it?! https://littlecms.com/blog/2020/12/09/using-lcms2-on-qt/

AndrewKeYanzhe commented 11 months ago

My understanding is, color management was working in older versions of MLV App, up to at least Qt 5.7 (Intel build). Qt draws in sRGB and tells macOS that the canvas is in sRGB, then macOS does the color management.

We are good for now with sRGB on macOS, and i can confirm as it changes appearance when I switch profiles.

https://github.com/ilia3101/MLV-App/issues/134#issuecomment-440080015

However, as mentioned in the Telegram desktop bug report, later versions of Qt 5.x stopped telling macOS that the canvas is in sRGB and color management no longer works.

The display is not of sRGB color space but Qt draws everything in sRGB while not telling about this to the system by default as the conversion is expensive for raster-based surfaces (they had this by default in early 5.x, but then reverted).

https://github.com/telegramdesktop/tdesktop/issues/26166#issuecomment-1505091292

Therefore MLV App using Qt 5.15.3 and Qt 5.15.10 (Apple silicon builds) do not have color management.

That was to be expected, that nothing changes. Why should it?

@masc4ii My intention is to see if Qt6 will fix this color management bug.

@ilia3101 which version of Qt is your MLV App build using?

masc4ii commented 11 months ago

That Telegram bug report indeed is very interesting! I tried adding the few lines of code mentioned - I can't see any change. But maybe I do it wrong.

    auto format = QSurfaceFormat::defaultFormat();
    format.setSwapInterval(0);
    format.setColorSpace( QSurfaceFormat::sRGBColorSpace );
    QSurfaceFormat::setDefaultFormat(format);

Building MLVApp is not that hard (a version which runs on your mac only). Install qt, qtcreator and llvm using brew. Load our .pro file into qtcreator and hit compile. As long as qtcreator auto-found the toolchain, that should be all.

masc4ii commented 11 months ago

Hm... the changes on my M1 monitor (when selecting between the profiles) now are by far more with this small change, instead trying same on Intel.

https://www.dropbox.com/scl/fi/fu5x1g3jgrqkqb3n681ir/MLV-App-1.15rc.zip?rlkey=e5gauoglmjxylyktnm5tfng2m&dl=0

Could you please try again if that is what you expect?

AndrewKeYanzhe commented 11 months ago

I have tested your new build (Qt 5.15.10) on my M1 Macbook Air and color management is working perfectly. Thank you so much for helping to fix it!

masc4ii commented 11 months ago

Ah cool. It is the code from your link. https://github.com/ilia3101/MLV-App/commit/7b3e2756578ff47909b325fdf449aa3a8d798499