flathub / tv.kodi.Kodi

https://flathub.org/apps/details/tv.kodi.Kodi
GNU Lesser General Public License v2.1
25 stars 24 forks source link

HDR shown in GUI but not working (flatpak currently built with GL renderer) #248

Open arigit opened 7 months ago

arigit commented 7 months ago

Running the kodi flatpak in GBM mode, on Intel N100 hardware, Samsung HDR-capable TV, latest flatpak (Kodi 21/Omega) In Settings > Information > Video, Kodi correctly detects that the TV supports HDR10 and HLG. In Settings > Media Player > Video, the HDR toggle is shown and HDR is enabled in my setup.

Kodi is also able to detect the HDR codec correctly in my HDR test videos.

When an HDR10 video is played back, Kodi does not attempt to switch on HDR mode in the TV and the TV shows it's in SDR mode. After a somewhat lengthy troubleshooting (trying things in the TV, changing the HDMI cable etc) I realized that the flatpak is using GL rendered instead of GLES, since the log shows entries such as:

: CLinuxRendererGL::UpdateVideoFilter Ask to maintainers: is it possible to create a beta flatpak build with GLES as renderer instead of GL? (or just switch to GLES)? So that we can test HDR and help stabilize the GLES renderer
razzeee commented 7 months ago

There is -DAPP_RENDER_SYSTEM="gles" (or "gl") which can only be set at build time

arigit commented 7 months ago

Thanks @razzeee , rebuilding the flatpak with GLES enabled. Will share results.

Recipe:

Kodi GLES (HDR support): Flatpak Build

cd ~./kodi-build
git clone https://github.com/flathub/tv.kodi.Kodi
cd tv.kodi.Kodi
vim tv.kodi.Kodi.yml   # change the kodi RENDER_SYSTEM from "gl" to "gles"
mkdir build
sudo flatpak-builder ./build --install-deps-from=flathub --ccache --force-clean tv.kodi.Kodi
flatpak build-export export build
flatpak build-bundle export kodi-gles.flatpak tv.kodi.Kodi

sudo systemctl stop kodi
sudo flatpak uninstall tv.kodi.Kodi  # this preserves the data in the .var folders of the different users
sudo flatpak install kodi-gles.flatpak
sudo systemctl start kodi
arigit commented 7 months ago

The flatpak rebuild with GLES enabled worked - the flatpak is now able to play all the test videos in my samsung TV (HDR10/HDR10+/HLG capable). For the first time ever I can see the TV switching to HDR mode and proper display of colors.

I could test this with multiple clips and content. Not sure why but HDR10+ content seems to work, at least it triggers HDR mode in the TV and the color saturation/contrast looks good. I read that kodi/ffmpeg is does not yet support dynamic hdr metadata so not sure why this seems to work.

Tested this build quite extensively with normal 'family' use cases and all looks very solid, no crashes whatsoever.

The only caveat I found is that the youtube addon does not seem to be able to play HDR content (this was the same in the GL build though), the TV switches to HDR mode (I can see that in the GUI color saturation change) but only audio is played. Could be my setup.

I'd suggest considering setting up a branch or alternate version in flathub with GLES so people can test it as this is the only way to get HDR working. I understand that GLES was adopted by libreelec, also used by android etc, so guaranteed support going forward on GLES.

jacen05 commented 3 months ago

Thanks @arigit for this recipe! I'm also on N100 but I had a little modification to do.

When following the exact instructions, I got HDR working (related setting available in Kodi, TV displaying HDR logo, and visual enhancement of picture quality), however I lost hardware decoding (no longer able to use VAAPI from what I understand), so 4K@60FPS was really laggy.

I needed to upgrade ffmpeg version in tv.kodi.Kodi.yml:

Then I did the build/export/install of the flatpak, and got both HW decoding and HDR working.

Hope it can help others.

I also have problems with HDR on the Youtube addon:

I guess that when Kodi will support latest ffmpeg it will work. In the meantime I have my video library in 4K HDR and Youtube in 4K without HDR, I can survive with that :smile:

razzeee commented 3 months ago

@jacen05 I've build https://github.com/flathub/tv.kodi.Kodi/pull/286#issuecomment-2297765835 - I guess you could play with that build

jacen05 commented 3 months ago

hi @razzeee ! Sorry but I fail to see what could bring this build, comparing to what I have now:

Of course, I would be pleased to have a GLES build available in Flathub, so if you do the build with GLES I'll test it!

razzeee commented 3 months ago

I guess it's not worth it, when kodi doesn't upgrade ffmpeg

simpledork47 commented 2 months ago

Thanks @arigit and @jacen05 by following your advices (rebuilding flatpak with mods), I've finally got my LG TV switching to "HDR" mode I'm using a N100 too

Regards