flathub / tv.kodi.Kodi

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

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

Open arigit opened 2 months ago

arigit commented 2 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 2 months ago

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

arigit commented 2 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 2 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.