croneter / PlexKodiConnect

Plex integration in Kodi done right
GNU General Public License v2.0
1.16k stars 77 forks source link

Nexus not importing the HDR Tag from Plex #1907

Closed JCalvi closed 1 year ago

JCalvi commented 1 year ago

I just updated to Nexus (v20) and followed the delete the .db files procedure.

Nexus now has a HDR tag so I hoped it would come across with PKC from Plex which knows which files are HDR.

Everything seems ok except the HDR tag does not seem to come across from Plex.

I haven't done much troubleshooting myself but note the following...

  1. Some tags appeared, I don't know if they came from Plex or if Kodi looked at the content and added the tags.
  2. If I mess around with a file sometimes the tag appears when it was not there before. I thought refreshing an individual item was adding them but after a couple worked, then I could no longer reproduce this.
  3. Wiping the database through Plex and rebuilding seems to wipe most of the HDR tags hence why I suspect PKC is not bringing them over.

I looked in MyVideos121.db and the tag appears to need to go into strHDRType in the streamDetails table.

Croneter, can you confirm if this tag should come across from Plex or if I need to do something more at my end to get it to work?

JCalvi commented 1 year ago

Croneter, here are my working mods to get HDR10 , HLG and Dolbyvision tag Plex>Kodi.

video.py Lines 538-548

        for videotrack in streamdetails['video']:
            self.cursor.execute('''
                INSERT OR REPLACE INTO streamdetails(
                    idFile, iStreamType, strVideoCodec, fVideoAspect,
                    iVideoWidth, iVideoHeight, iVideoDuration ,strStereoMode, strHdrType)
                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
                ''', (fileid, 0, videotrack['codec'],
                      videotrack['aspect'], videotrack['width'],
                      videotrack['height'], runtime,
                      videotrack['video3DFormat'],
                      videotrack['hdr']))

media.py lines 175-183* (Refer post below as bt2020 check not required)

                    track['video3DFormat'] = None
                    colorTrc = stream.get('colorTrc',"").lower()
                    colorPrimaries = stream.get('colorPrimaries',"").lower()
                    if "smpte2084" in colorTrc:
                        track['hdr'] = "hdr10"
                    elif "arib-std-b67" in colorTrc:
                        track['hdr'] = "hlg"
                    elif "bt2020" in colorPrimaries:
                        track['hdr'] = "hdr10"
                    else:
                        track['hdr'] = None                    
                    if (cast(bool,stream.get('DOVIPresent'))):
                        track['hdr'] = "dolbyvision"
                    videotracks.append(track)

Cheers, JC.

Shawn9347 commented 1 year ago

I applied your mods. But, what do you mean by tags? I don't see those hdr tags anywhere. Also, I can't find any changelog that says that Nexus supports this now.

JCalvi commented 1 year ago

Bottom of list views, in info etc. No, not in changelog, but trust me it's there. You can add a source and use Kodi to parse it directly and it will detect Dolbyvision, HDR10 and HLG files. Matrix had no such feature. strHdrType has been added to the database and 3 icons added to the textures and estuary skin. Check with estuary skin as others may not have caught up yet.

TVShow Widelist View (Bottom of screen, episode selected that has Dolbyvision) DV

Movie List View (Bottom of screen, movie selected that is HDR10) HDR10

Kodi Library Scraper (Not PlexKodiConnect) - Video Widelist View (Bottom of screen, file selected that is HLG) HLG

I have tested HLG through Plex and it also works fine in passing the data and activating the HLG icon.

The tricky part was to work through the Python Plex API and work out how to tell these three types apart and pass the also undocumented correct strings to Kodi for its database. My changes work for all the files I have tested but could do with more testing no doubt. Plex has a Bool for Dolbyvision detected or not. HLG should always have a color trc of arib-std-b67 (AFAIK) HDR10 should always be SMTPE2084, but I have a fall back to check for BT2020 as well. A weird file like SDR that someone mapped to BT2020 will get flagged as HDR10 and if this turns out to be an issue the fallback check can be removed. I haven't done any exhaustive checking to see if its really needed.

JC.

Shawn9347 commented 1 year ago

Oh okay. Nice. I don't see them tho. Neither in Estuary. Is there anything I need to enable for this to appear?

JCalvi commented 1 year ago

You will need to do a full reimport with plexkodiconnect as this won’t be seen as a change to items already in the database.

Just go to PKC settings>advanced, repair database. This is for existing items, after this new items will get picked up.

JCalvi commented 1 year ago

I just did a test and as suspected bt2020 is not required, all hdr10 get smtpe2084 from plex. (as does Dolbyvision BTW).

so media.py can be reduced to:

media.py lines 174-184

                    track['video3DFormat'] = None
                    colorTrc = stream.get('colorTrc',"").lower()
                    if "smpte2084" in colorTrc:
                        track['hdr'] = "hdr10"
                    elif "arib-std-b67" in colorTrc:
                        track['hdr'] = "hlg"
                    else:
                        track['hdr'] = None                    
                    if (cast(bool,stream.get('DOVIPresent'))):
                        track['hdr'] = "dolbyvision"
                    videotracks.append(track)

Cheers, JC.

Shawn9347 commented 1 year ago

Thank you. I will test once I get home tonight.

hamakavula commented 1 year ago

FYI: In my config, the HDR tag DOES show up but when playing the file... noticed after upgrading to Nexus (clean install & reconfigure) (on Shield TV Pro 8.2.3, Android 9, Kodi Nexus, PKC latest, Estuary MOD v2 Nexus edition)

image

But not in the the tags below (Skin does not support it, I suppose). image

Good luck and thanks for all the hard work!

Shawn9347 commented 1 year ago

It works for me as well. But I use arctic horizon 2 which doesn't support the tags yet.

You dutch btw?

hamakavula commented 1 year ago

You dutch btw? Jep

croneter commented 1 year ago

Should be solved in PKC Beta version 3.7.2. Thanks a ton @JCalvi

croneter commented 1 year ago

Respective commit as the PR got lost: https://github.com/croneter/PlexKodiConnect/commit/664a68c30fe4bca9e191acad2b2aa8850859b0ba