Merge pull request #1309 from croneter/fix-streams

Fix PKC not auto-picking audio/subtitle stream when transcoding
This commit is contained in:
croneter 2021-01-28 13:06:28 +01:00 committed by GitHub
commit f6e54ac2b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 19 deletions

View file

@ -634,7 +634,7 @@ msgstr ""
# PKC Settings - Playback # PKC Settings - Playback
msgctxt "#30541" msgctxt "#30541"
msgid "Don't ask to pick a certain stream/quality" msgid "Transcoding: Auto-pick audio and subtitle stream using Plex defaults"
msgstr "" msgstr ""
# PKC Settings - Playback # PKC Settings - Playback

View file

@ -348,8 +348,14 @@ def audio_subtitle_prefs(api, item):
action_type='PUT', action_type='PUT',
parameters=args) parameters=args)
return True return True
return setup_transcoding_audio_subtitle_prefs(mediastreams, part_id)
def setup_transcoding_audio_subtitle_prefs(mediastreams, part_id):
audio_streams_list = [] audio_streams_list = []
audio_streams = [] audio_streams = []
audio_default = None
subtitle_default = None
subtitle_streams_list = [] subtitle_streams_list = []
# "Don't burn-in any subtitle" # "Don't burn-in any subtitle"
subtitle_streams = ['1 %s' % utils.lang(39706)] subtitle_streams = ['1 %s' % utils.lang(39706)]
@ -378,6 +384,8 @@ def audio_subtitle_prefs(api, item):
utils.lang(39707), # unknown utils.lang(39707), # unknown
codec, codec,
channellayout) channellayout)
if stream.get('default'):
audio_default = audio_numb
audio_streams_list.append(index) audio_streams_list.append(index)
audio_streams.append(track) audio_streams.append(track)
audio_numb += 1 audio_numb += 1
@ -390,7 +398,6 @@ def audio_subtitle_prefs(api, item):
continue continue
# Subtitle is available within the video file # Subtitle is available within the video file
# Burn in the subtitle, if user chooses to do so # Burn in the subtitle, if user chooses to do so
default = stream.get('default')
forced = stream.get('forced') forced = stream.get('forced')
try: try:
track = '{} {}'.format(sub_num + 1, track = '{} {}'.format(sub_num + 1,
@ -399,7 +406,8 @@ def audio_subtitle_prefs(api, item):
track = '{} {} ({})'.format(sub_num + 1, track = '{} {} ({})'.format(sub_num + 1,
utils.lang(39707), # unknown utils.lang(39707), # unknown
stream.get('codec')) stream.get('codec'))
if default: if stream.get('default'):
subtitle_default = sub_num
track = "%s - %s" % (track, utils.lang(39708)) # Default track = "%s - %s" % (track, utils.lang(39708)) # Default
if forced: if forced:
track = "%s - %s" % (track, utils.lang(39709)) # Forced track = "%s - %s" % (track, utils.lang(39709)) # Forced
@ -409,10 +417,14 @@ def audio_subtitle_prefs(api, item):
sub_num += 1 sub_num += 1
if audio_numb > 1: if audio_numb > 1:
resp = utils.dialog('select', utils.lang(33013), audio_streams) # "Transcoding: Auto-pick audio and subtitle stream using Plex defaults"
if resp == -1: if utils.settings('bestQuality') == 'true' and audio_default is not None:
LOG.info('User aborted dialog to select audio stream') resp = audio_default
return else:
resp = utils.dialog('select', utils.lang(33013), audio_streams)
if resp == -1:
LOG.info('User aborted dialog to select audio stream')
return
args = { args = {
'audioStreamID': audio_streams_list[resp], 'audioStreamID': audio_streams_list[resp],
'allParts': 1 'allParts': 1
@ -427,18 +439,22 @@ def audio_subtitle_prefs(api, item):
# Otherwise, the PMS might pick-up the last one # Otherwise, the PMS might pick-up the last one
LOG.info('No subtitles to burn-in') LOG.info('No subtitles to burn-in')
else: else:
resp = utils.dialog('select', utils.lang(33014), subtitle_streams) # "Transcoding: Auto-pick audio and subtitle stream using Plex defaults"
if resp == -1: if utils.settings('bestQuality') == 'true' and subtitle_default is not None:
LOG.info('User aborted dialog to select subtitle stream') resp = subtitle_default
return
elif resp == 0:
# User did not select a subtitle or backed out of the dialog
LOG.info('User chose to not burn-in any subtitles')
else: else:
LOG.info('User chose to burn-in subtitle %s: %s', resp = utils.dialog('select', utils.lang(33014), subtitle_streams)
select_subs_index, if resp == -1:
subtitle_streams[resp]) LOG.info('User aborted dialog to select subtitle stream')
select_subs_index = subtitle_streams_list[resp - 1] return
elif resp == 0:
# User did not select a subtitle or backed out of the dialog
LOG.info('User chose to not burn-in any subtitles')
else:
LOG.info('User chose to burn-in subtitle %s: %s',
select_subs_index,
subtitle_streams[resp])
select_subs_index = subtitle_streams_list[resp - 1]
# Now prep the PMS for our choice # Now prep the PMS for our choice
args = { args = {
'subtitleStreamID': select_subs_index, 'subtitleStreamID': select_subs_index,

View file

@ -120,7 +120,7 @@
<setting id="audioBoost" type="slider" label="39001" default="0" range="0,10,100" option="int"/> <setting id="audioBoost" type="slider" label="39001" default="0" range="0,10,100" option="int"/>
<setting id="subtitleSize" label="39002" type="slider" option="int" range="0,30,300" default="100" /> <setting id="subtitleSize" label="39002" type="slider" option="int" range="0,30,300" default="100" />
<setting id="force_transcode_pix" type="bool" label="30545" default="false" /> <setting id="force_transcode_pix" type="bool" label="30545" default="false" />
<setting id="bestQuality" type="bool" label="30541" default="false" /> <setting id="bestQuality" type="bool" label="30541" default="false" /><!-- Transcoding: Auto-pick audio and subtitle stream using Plex defaults -->
<setting id="bestTrailer" type="bool" label="30542" default="true" /> <setting id="bestTrailer" type="bool" label="30542" default="true" />
<setting type="sep" /> <setting type="sep" />
<setting id="offerDelete" type="bool" label="30114" default="false" visible="false"/> <setting id="offerDelete" type="bool" label="30114" default="false" visible="false"/>