|
|
@ -615,6 +615,29 @@ def convert(ctx,
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
sourceStreamDescriptor = getStreamDescriptor(sourcePath)
|
|
|
|
sourceStreamDescriptor = getStreamDescriptor(sourcePath)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure disposition and tags keys for every stream
|
|
|
|
|
|
|
|
for substreamIndex in range(len(sourceStreamDescriptor[STREAM_TYPE_AUDIO])):
|
|
|
|
|
|
|
|
if not 'disposition' in sourceStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex].keys():
|
|
|
|
|
|
|
|
sourceStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition'] = {}
|
|
|
|
|
|
|
|
if not 'default' in sourceStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition'].keys():
|
|
|
|
|
|
|
|
sourceStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition']['default'] = 0
|
|
|
|
|
|
|
|
if not 'forced' in sourceStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition'].keys():
|
|
|
|
|
|
|
|
sourceStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition']['forced'] = 0
|
|
|
|
|
|
|
|
for substreamIndex in range(len(sourceStreamDescriptor[STREAM_TYPE_AUDIO])):
|
|
|
|
|
|
|
|
if not 'tags' in sourceStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex].keys():
|
|
|
|
|
|
|
|
sourceStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['tags'] = {}
|
|
|
|
|
|
|
|
for substreamIndex in range(len(sourceStreamDescriptor[STREAM_TYPE_SUBTITLE])):
|
|
|
|
|
|
|
|
if not 'disposition' in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex].keys():
|
|
|
|
|
|
|
|
sourceStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition'] = {}
|
|
|
|
|
|
|
|
if not 'default' in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition'].keys():
|
|
|
|
|
|
|
|
sourceStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition']['default'] = 0
|
|
|
|
|
|
|
|
if not 'forced' in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition'].keys():
|
|
|
|
|
|
|
|
sourceStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition']['forced'] = 0
|
|
|
|
|
|
|
|
for substreamIndex in range(len(sourceStreamDescriptor[STREAM_TYPE_SUBTITLE])):
|
|
|
|
|
|
|
|
if not 'tags' in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex].keys():
|
|
|
|
|
|
|
|
sourceStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['tags'] = {}
|
|
|
|
|
|
|
|
|
|
|
|
targetStreamDescriptor = sourceStreamDescriptor.copy()
|
|
|
|
targetStreamDescriptor = sourceStreamDescriptor.copy()
|
|
|
|
|
|
|
|
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
@ -631,23 +654,19 @@ def convert(ctx,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#NOTE: It is currently expected that all source file have the same substream pattern, e.g. coming from the same encoder
|
|
|
|
#NOTE: It is currently expected that all source file have the same substream pattern, e.g. coming from the same encoder
|
|
|
|
defaultAudioStreams = [a for a in sourceStreamDescriptor[STREAM_TYPE_AUDIO] if 'disposition' in a.keys() and 'default' in a['disposition'].keys() and a['disposition']['default'] == 1]
|
|
|
|
defaultAudioStreams = [a for a in sourceStreamDescriptor[STREAM_TYPE_AUDIO] if a['disposition']['default'] == 1]
|
|
|
|
|
|
|
|
|
|
|
|
if default_audio == -1 and len(defaultAudioStreams) > 1:
|
|
|
|
if default_audio == -1 and len(defaultAudioStreams) > 1:
|
|
|
|
default_audio = click.prompt("More than one default audio stream detected! Please select stream", type=int)
|
|
|
|
default_audio = click.prompt("More than one default audio stream detected! Please select stream", type=int)
|
|
|
|
|
|
|
|
|
|
|
|
forcedAudioStreams = [a for a in sourceStreamDescriptor[STREAM_TYPE_AUDIO] if 'disposition' in a.keys() and 'default' in a['disposition'].keys() and a['disposition']['forced'] == 1]
|
|
|
|
forcedAudioStreams = [a for a in sourceStreamDescriptor[STREAM_TYPE_AUDIO] if a['disposition']['forced'] == 1]
|
|
|
|
|
|
|
|
|
|
|
|
if forced_audio == -1 and len(forcedAudioStreams) > 1:
|
|
|
|
if forced_audio == -1 and len(forcedAudioStreams) > 1:
|
|
|
|
forced_audio = click.prompt("More than one forced audio stream detected! Please select stream", type=int)
|
|
|
|
forced_audio = click.prompt("More than one forced audio stream detected! Please select stream", type=int)
|
|
|
|
|
|
|
|
|
|
|
|
defaultSubtitleStreams = [s for s in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE] if 'disposition' in s.keys() and 'default' in s['disposition'].keys() and s['disposition']['default'] == 1]
|
|
|
|
defaultSubtitleStreams = [s for s in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE] if s['disposition']['default'] == 1]
|
|
|
|
|
|
|
|
|
|
|
|
if default_subtitle == -1 and len(defaultSubtitleStreams) > 1:
|
|
|
|
if default_subtitle == -1 and len(defaultSubtitleStreams) > 1:
|
|
|
|
default_subtitle = click.prompt("More than one default subtitle stream detected! Please select stream", type=int)
|
|
|
|
default_subtitle = click.prompt("More than one default subtitle stream detected! Please select stream", type=int)
|
|
|
|
|
|
|
|
|
|
|
|
forcedSubtitleStreams = [s for s in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE] if 'disposition' in s.keys() and 'default' in s['disposition'].keys() and s['disposition']['forced'] == 1]
|
|
|
|
forcedSubtitleStreams = [s for s in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE] if s['disposition']['forced'] == 1]
|
|
|
|
|
|
|
|
|
|
|
|
if forced_subtitle == -1 and len(forcedSubtitleStreams) > 1:
|
|
|
|
if forced_subtitle == -1 and len(forcedSubtitleStreams) > 1:
|
|
|
|
forced_subtitle = click.prompt("More than one forced subtitle stream detected! Please select stream", type=int)
|
|
|
|
forced_subtitle = click.prompt("More than one forced subtitle stream detected! Please select stream", type=int)
|
|
|
|
|
|
|
|
|
|
|
@ -655,23 +674,15 @@ def convert(ctx,
|
|
|
|
#Fix multiple default/forced tags
|
|
|
|
#Fix multiple default/forced tags
|
|
|
|
if default_audio != -1:
|
|
|
|
if default_audio != -1:
|
|
|
|
for substreamIndex in range(len(targetStreamDescriptor[STREAM_TYPE_AUDIO])):
|
|
|
|
for substreamIndex in range(len(targetStreamDescriptor[STREAM_TYPE_AUDIO])):
|
|
|
|
if not 'disposition' in targetStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex].keys():
|
|
|
|
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition'] = {}
|
|
|
|
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition']['default'] = 1 if substreamIndex == default_audio else 0
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition']['default'] = 1 if substreamIndex == default_audio else 0
|
|
|
|
if forced_audio != -1:
|
|
|
|
if forced_audio != -1:
|
|
|
|
for substreamIndex in range(len(targetStreamDescriptor[STREAM_TYPE_AUDIO])):
|
|
|
|
for substreamIndex in range(len(targetStreamDescriptor[STREAM_TYPE_AUDIO])):
|
|
|
|
if not 'disposition' in targetStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex].keys():
|
|
|
|
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition'] = {}
|
|
|
|
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition']['forced'] = 1 if substreamIndex == forced_audio else 0
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_AUDIO][substreamIndex]['disposition']['forced'] = 1 if substreamIndex == forced_audio else 0
|
|
|
|
if default_subtitle != -1:
|
|
|
|
if default_subtitle != -1:
|
|
|
|
for substreamIndex in range(len(targetStreamDescriptor[STREAM_TYPE_SUBTITLE])):
|
|
|
|
for substreamIndex in range(len(targetStreamDescriptor[STREAM_TYPE_SUBTITLE])):
|
|
|
|
if not 'disposition' in targetStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex].keys():
|
|
|
|
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition'] = {}
|
|
|
|
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition']['default'] = 1 if substreamIndex == default_subtitle else 0
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition']['default'] = 1 if substreamIndex == default_subtitle else 0
|
|
|
|
if forced_subtitle != -1:
|
|
|
|
if forced_subtitle != -1:
|
|
|
|
for substreamIndex in range(len(targetStreamDescriptor[STREAM_TYPE_SUBTITLE])):
|
|
|
|
for substreamIndex in range(len(targetStreamDescriptor[STREAM_TYPE_SUBTITLE])):
|
|
|
|
if not 'disposition' in targetStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex].keys():
|
|
|
|
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition'] = {}
|
|
|
|
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition']['forded'] = 1 if substreamIndex == forced_subtitle else 0
|
|
|
|
targetStreamDescriptor[STREAM_TYPE_SUBTITLE][substreamIndex]['disposition']['forded'] = 1 if substreamIndex == forced_subtitle else 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|