mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
OP-4643 - split command line arguments to separate items
Reuse existing method from ExtractReview, put it into transcoding.py
This commit is contained in:
parent
78933eb562
commit
deaad39437
2 changed files with 31 additions and 25 deletions
|
|
@ -1092,7 +1092,7 @@ def convert_colorspace(
|
|||
raise ValueError("Both screen and display must be set.")
|
||||
|
||||
if additional_command_args:
|
||||
oiio_cmd.extend(additional_command_args)
|
||||
oiio_cmd.extend(split_cmd_args(additional_command_args))
|
||||
|
||||
if target_colorspace:
|
||||
oiio_cmd.extend(["--colorconvert",
|
||||
|
|
@ -1106,3 +1106,30 @@ def convert_colorspace(
|
|||
|
||||
logger.debug("Conversion command: {}".format(" ".join(oiio_cmd)))
|
||||
run_subprocess(oiio_cmd, logger=logger)
|
||||
|
||||
|
||||
def split_cmd_args(in_args):
|
||||
"""Makes sure all entered arguments are separated in individual items.
|
||||
|
||||
Split each argument string with " -" to identify if string contains
|
||||
one or more arguments.
|
||||
Args:
|
||||
in_args (list): of arguments ['-n', '-d uint10']
|
||||
Returns
|
||||
(list): ['-n', '-d', 'unint10']
|
||||
"""
|
||||
splitted_args = []
|
||||
for arg in in_args:
|
||||
sub_args = arg.split(" -")
|
||||
if len(sub_args) == 1:
|
||||
if arg and arg not in splitted_args:
|
||||
splitted_args.append(arg)
|
||||
continue
|
||||
|
||||
for idx, arg in enumerate(sub_args):
|
||||
if idx != 0:
|
||||
arg = "-" + arg
|
||||
|
||||
if arg and arg not in splitted_args:
|
||||
splitted_args.append(arg)
|
||||
return splitted_args
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from openpype.lib.transcoding import (
|
|||
should_convert_for_ffmpeg,
|
||||
convert_input_paths_for_ffmpeg,
|
||||
get_transcode_temp_directory,
|
||||
split_cmd_args
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -670,7 +671,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
res_filters = self.rescaling_filters(temp_data, output_def, new_repre)
|
||||
ffmpeg_video_filters.extend(res_filters)
|
||||
|
||||
ffmpeg_input_args = self.split_ffmpeg_args(ffmpeg_input_args)
|
||||
ffmpeg_input_args = split_cmd_args(ffmpeg_input_args)
|
||||
|
||||
lut_filters = self.lut_filters(new_repre, instance, ffmpeg_input_args)
|
||||
ffmpeg_video_filters.extend(lut_filters)
|
||||
|
|
@ -723,28 +724,6 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
ffmpeg_output_args
|
||||
)
|
||||
|
||||
def split_ffmpeg_args(self, in_args):
|
||||
"""Makes sure all entered arguments are separated in individual items.
|
||||
|
||||
Split each argument string with " -" to identify if string contains
|
||||
one or more arguments.
|
||||
"""
|
||||
splitted_args = []
|
||||
for arg in in_args:
|
||||
sub_args = arg.split(" -")
|
||||
if len(sub_args) == 1:
|
||||
if arg and arg not in splitted_args:
|
||||
splitted_args.append(arg)
|
||||
continue
|
||||
|
||||
for idx, arg in enumerate(sub_args):
|
||||
if idx != 0:
|
||||
arg = "-" + arg
|
||||
|
||||
if arg and arg not in splitted_args:
|
||||
splitted_args.append(arg)
|
||||
return splitted_args
|
||||
|
||||
def ffmpeg_full_args(
|
||||
self, input_args, video_filters, audio_filters, output_args
|
||||
):
|
||||
|
|
@ -764,7 +743,7 @@ class ExtractReview(pyblish.api.InstancePlugin):
|
|||
Returns:
|
||||
list: Containing all arguments ready to run in subprocess.
|
||||
"""
|
||||
output_args = self.split_ffmpeg_args(output_args)
|
||||
output_args = split_cmd_args(output_args)
|
||||
|
||||
video_args_dentifiers = ["-vf", "-filter:v"]
|
||||
audio_args_dentifiers = ["-af", "-filter:a"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue