|
|
|
@ -450,6 +450,7 @@ def streams(filename):
|
|
|
|
|
@click.option('-at', '--audio-title', type=str, multiple=True, help='Audio stream title(s)')
|
|
|
|
|
|
|
|
|
|
@click.option('-da', '--default-audio', type=int, default=-1, help='Index of default audio stream')
|
|
|
|
|
@click.option('-da', '--forced-audio', type=int, default=-1, help='Index of forced audio stream')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.option("--crop", is_flag=False, flag_value="default", default="none")
|
|
|
|
@ -483,6 +484,7 @@ def convert(ctx,
|
|
|
|
|
audio_language,
|
|
|
|
|
audio_title,
|
|
|
|
|
default_audio,
|
|
|
|
|
forced_audio,
|
|
|
|
|
crop,
|
|
|
|
|
output_directory,
|
|
|
|
|
clear_metadata,
|
|
|
|
@ -619,11 +621,67 @@ def convert(ctx,
|
|
|
|
|
click.echo(f"File with path {sourcePath} does not contain any audiovisual data, skipping ...")
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
click.echo('Source streans:')
|
|
|
|
|
for aStream in sourceStreamDescriptor[STREAM_TYPE_AUDIO]:
|
|
|
|
|
click.echo(f"audio stream lang={aStream['language']}")
|
|
|
|
|
click.echo(f"audio stream {aStream['src_sub_index']} lang={aStream['language']} title={aStream['title']} default={aStream['disposition']['default']} forced={aStream['disposition']['forced']}")
|
|
|
|
|
|
|
|
|
|
for sStream in sourceStreamDescriptor[STREAM_TYPE_SUBTITLE]:
|
|
|
|
|
click.echo(f"subtitle stream lang={sStream['language']}")
|
|
|
|
|
click.echo(f"subtitle stream {sStream['src_sub_index']} lang={sStream['language']} title={sStream['title']} default={sStream['disposition']['default']} forced={sStream['disposition']['forced']}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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]
|
|
|
|
|
|
|
|
|
|
if default_audio == -1 and len(defaultAudioStreams) > 1:
|
|
|
|
|
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]
|
|
|
|
|
|
|
|
|
|
if forced_audio == -1 and len(forcedAudioStreams) > 1:
|
|
|
|
|
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]
|
|
|
|
|
|
|
|
|
|
if default_subtitle == -1 and len(defaultSubtitleStreams) > 1:
|
|
|
|
|
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]
|
|
|
|
|
|
|
|
|
|
if forced_subtitle == -1 and len(forcedSubtitleStreams) > 1:
|
|
|
|
|
forced_subtitle = click.prompt("More than one forced subtitle stream detected! Please select stream", type=int)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Fix multiple default/forced tags
|
|
|
|
|
if default_audio != -1:
|
|
|
|
|
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
|
|
|
|
|
if forced_audio != -1:
|
|
|
|
|
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
|
|
|
|
|
if default_subtitle != -1:
|
|
|
|
|
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
|
|
|
|
|
if forced_subtitle != -1:
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
click.echo('Target streans:')
|
|
|
|
|
for aStream in targetStreamDescriptor[STREAM_TYPE_AUDIO]:
|
|
|
|
|
click.echo(f"audio stream {aStream['src_sub_index']} lang={aStream['language']} title={aStream['title']} default={aStream['disposition']['default']} forced={aStream['disposition']['forced']}")
|
|
|
|
|
|
|
|
|
|
for sStream in targetStreamDescriptor[STREAM_TYPE_SUBTITLE]:
|
|
|
|
|
click.echo(f"subtitle stream {sStream['src_sub_index']} lang={sStream['language']} title={sStream['title']} default={sStream['disposition']['default']} forced={sStream['disposition']['forced']}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commandTokens = COMMAND_TOKENS + ['-i', sourcePath]
|
|
|
|
|