Adapt unmux command to changes in convert command
This commit is contained in:
@@ -47,6 +47,10 @@ SUBTITLE_PREFIX_OPTION_HELP = (
|
||||
"Subtitle filename prefix. Requires --subtitle-directory, or a configured "
|
||||
+ "subtitlesDirectory base path that contains a matching <prefix>/ subdirectory."
|
||||
)
|
||||
UNMUX_OUTPUT_DIRECTORY_OPTION_HELP = (
|
||||
"Write extracted streams here. When omitted together with --subtitles-only and "
|
||||
+ "--label, FFX uses the configured subtitlesDirectory base path plus the label."
|
||||
)
|
||||
CROPDETECT_SEEK_OPTION_HELP = (
|
||||
"Start crop detection this many seconds into the input. "
|
||||
+ "Useful for skipping logos, intros, or black frames."
|
||||
@@ -160,6 +164,27 @@ def resolveSubtitleImportOptions(context, subtitleDirectory, subtitlePrefix):
|
||||
return True, resolvedSubtitleDirectory, resolvedSubtitlePrefix
|
||||
|
||||
|
||||
def resolveUnmuxOutputDirectory(context, outputDirectory, subtitlesOnly, label):
|
||||
resolvedOutputDirectory = (
|
||||
os.path.expanduser(str(outputDirectory).strip())
|
||||
if outputDirectory
|
||||
else ''
|
||||
)
|
||||
resolvedLabel = str(label).strip()
|
||||
|
||||
if resolvedOutputDirectory or not subtitlesOnly or not resolvedLabel:
|
||||
return resolvedOutputDirectory, False
|
||||
|
||||
configuredSubtitlesBaseDirectory = context['config'].getSubtitlesDirectoryPath()
|
||||
if not configuredSubtitlesBaseDirectory:
|
||||
raise click.ClickException(
|
||||
"Subtitles-only unmux with --label requires --output-directory or a configured "
|
||||
+ "subtitlesDirectory default in ffx.json."
|
||||
)
|
||||
|
||||
return os.path.join(configuredSubtitlesBaseDirectory, resolvedLabel), True
|
||||
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.pass_context
|
||||
@@ -416,7 +441,7 @@ def getUnmuxSequence(trackDescriptor: TrackDescriptor, sourcePath, targetPrefix,
|
||||
|
||||
@click.argument('paths', nargs=-1)
|
||||
@click.option('-l', '--label', type=str, default='', help='Label to be used as filename prefix')
|
||||
@click.option("-o", "--output-directory", type=str, default='')
|
||||
@click.option("-o", "--output-directory", type=str, default='', help=UNMUX_OUTPUT_DIRECTORY_OPTION_HELP)
|
||||
@click.option("-s", "--subtitles-only", is_flag=True, default=False)
|
||||
@click.option(
|
||||
'--nice',
|
||||
@@ -454,6 +479,15 @@ def unmux(ctx,
|
||||
ctx.obj['resource_limits']['cpu_limit'] = cpu
|
||||
ctx.obj['resource_limits']['cpu_percent'] = cpu
|
||||
|
||||
output_directory, create_output_directory = resolveUnmuxOutputDirectory(
|
||||
ctx.obj,
|
||||
output_directory,
|
||||
subtitles_only,
|
||||
label,
|
||||
)
|
||||
if create_output_directory and existingSourcePaths and not ctx.obj.get('dry_run', False):
|
||||
os.makedirs(output_directory, exist_ok=True)
|
||||
|
||||
for sourcePath in existingSourcePaths:
|
||||
|
||||
fp = FileProperties(ctx.obj, sourcePath)
|
||||
|
||||
Reference in New Issue
Block a user