From a7057ec3dc760c70a521a2d196ae76519858a070 Mon Sep 17 00:00:00 2001 From: simpman Date: Thu, 7 Dec 2017 01:03:31 -0700 Subject: [PATCH] Improve transcoding detection (#107) * Update Leia Video DB * Fix transcoding for non-standard filenames Fix transcoding for cases where the filename does not contain codec Added HEVC to 10bit transcode option Added case for non-default video track ids --- resources/lib/database.py | 4 ++-- resources/lib/playutils.py | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/resources/lib/database.py b/resources/lib/database.py index 17717c57..ad7bfd91 100644 --- a/resources/lib/database.py +++ b/resources/lib/database.py @@ -30,7 +30,7 @@ def video_database(): '15': 93, # Isengard '16': 99, # Jarvis '17': 107,# Krypton - '18': 108 # Leia + '18': 109 # Leia } return xbmc.translatePath("special://database/MyVideos%s.db" % db_version.get(KODI, "")).decode('utf-8') @@ -244,4 +244,4 @@ def db_reset(): except: pass - \ No newline at end of file + diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index 2a424459..fb92e20e 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -138,13 +138,14 @@ class PlayUtils(): # User forcing to play via HTTP log.info("Can't direct play, play from HTTP enabled.") return False - - videotrack = self.item['MediaSources'][0]['Name'] + + vid = self.getVideoStreamID() + videotrack = self.item['MediaStreams'][vid]['DisplayTitle'] transcodeH265 = settings('transcodeH265') - videoprofiles = [x['Profile'] for x in self.item['MediaSources'][0]['MediaStreams'] if 'Profile' in x] + videoprofile = self.item['MediaStreams'][vid]['Profile'] transcodeHi10P = settings('transcodeHi10P') - if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofiles: + if transcodeHi10P == "true" and ("Main 10" in videoprofile or "High 10" in videoprofile) and ("H264" in videotrack or "H265" in videotrack or "HEVC" in videotrack): return False if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack): @@ -241,13 +242,14 @@ class PlayUtils(): return False def isDirectStream(self): - - videotrack = self.item['MediaSources'][0]['Name'] + + vid = self.getVideoStreamID() + videotrack = self.item['MediaStreams'][vid]['DisplayTitle'] transcodeH265 = settings('transcodeH265') - videoprofiles = [x['Profile'] for x in self.item['MediaSources'][0]['MediaStreams'] if 'Profile' in x] + videoprofile = self.item['MediaStreams'][vid]['Profile'] transcodeHi10P = settings('transcodeHi10P') - if transcodeHi10P == "true" and "H264" in videotrack and "High 10" in videoprofiles: + if transcodeHi10P == "true" and ("Main 10" in videoprofile or "High 10" in videoprofile) and ("H264" in videotrack or "H265" in videotrack or "HEVC" in videotrack): return False if transcodeH265 in ("1", "2", "3") and ("HEVC" in videotrack or "H265" in videotrack): @@ -703,3 +705,7 @@ class PlayUtils(): except KeyError as error: return False + def getVideoStreamID(self): + # Sometimes video stream is not 0, this locates it. + videx = [x['Index'] for x in self.item['MediaSources'][0]['MediaStreams'] if 'Video' in x['Type']] + return videx[0]