playutils: Always honor manual transcoding bitrates

* Override VideoBitrate option in transcoding url (previously calced in backend)
* Use manual AudioBitrate when user has track selection dialog disabled
* Fix bad loop-and-remove
This commit is contained in:
Michal Chvíla 2020-09-15 01:09:02 +02:00
parent e651b66ddc
commit fea6fc4cf1
1 changed files with 12 additions and 6 deletions

View File

@ -241,15 +241,22 @@ class PlayUtils(object):
if self.item['MediaType'] == 'Video': if self.item['MediaType'] == 'Video':
base, params = source['TranscodingUrl'].split('?') base, params = source['TranscodingUrl'].split('?')
url_parsed = params.split('&')
manual_tracks = ''
# manual bitrate
url_parsed = [p for p in url_parsed if 'AudioBitrate' not in p and 'VideoBitrate' not in p]
if settings('skipDialogTranscode') != "3" and source.get('MediaStreams'): if settings('skipDialogTranscode') != "3" and source.get('MediaStreams'):
url_parsed = params.split('&') # manual tracks
url_parsed = [p for p in url_parsed if 'AudioStreamIndex' not in p and 'SubtitleStreamIndex' not in p]
manual_tracks = self.get_audio_subs(source, audio, subtitle)
for i in url_parsed: audio_bitrate = self.get_transcoding_audio_bitrate()
if 'AudioStreamIndex' in i or 'AudioBitrate' in i or 'SubtitleStreamIndex' in i: # handle manually video_bitrate = self.get_max_bitrate() - audio_bitrate
url_parsed.remove(i)
params = "%s%s" % ('&'.join(url_parsed), self.get_audio_subs(source, audio, subtitle)) params = "%s%s" % ('&'.join(url_parsed), manual_tracks)
params += "&VideoBitrate=%s&AudioBitrate=%s" % (video_bitrate, audio_bitrate)
video_type = 'live' if source['Protocol'] == 'LiveTV' else 'master' video_type = 'live' if source['Protocol'] == 'LiveTV' else 'master'
base = base.replace('stream' if 'stream' in base else 'master', video_type, 1) base = base.replace('stream' if 'stream' in base else 'master', video_type, 1)
@ -643,7 +650,6 @@ class PlayUtils(object):
self.info['AudioStreamIndex'] = audio_selected self.info['AudioStreamIndex'] = audio_selected
prefs += "&AudioStreamIndex=%s" % audio_selected prefs += "&AudioStreamIndex=%s" % audio_selected
prefs += "&AudioBitrate=%d" % self.get_transcoding_audio_bitrate()
if subtitle: if subtitle: