From 13fcfd0ae548bc7f02b206f98490b48befd12c3b Mon Sep 17 00:00:00 2001 From: Utku Demir Date: Mon, 11 Apr 2022 21:51:29 +1200 Subject: [PATCH] Introduce script_filename parameter --- ffmpeg/_run.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ffmpeg/_run.py b/ffmpeg/_run.py index f42d1d7..f4e9e59 100644 --- a/ffmpeg/_run.py +++ b/ffmpeg/_run.py @@ -149,7 +149,7 @@ def _get_output_args(node, stream_name_map): @output_operator() -def get_args(stream_spec, overwrite_output=False): +def get_args(stream_spec, overwrite_output=False, script_filename=None): """Build command-line arguments to be passed to ffmpeg.""" nodes = get_stream_spec_nodes(stream_spec) args = [] @@ -163,7 +163,11 @@ def get_args(stream_spec, overwrite_output=False): filter_arg = _get_filter_arg(filter_nodes, outgoing_edge_maps, stream_name_map) args += reduce(operator.add, [_get_input_args(node) for node in input_nodes]) if filter_arg: - args += ['-filter_complex', filter_arg] + if script_filename: + with open(script_filename, "w") as f: f.write(filter_arg) + args += ['-filter_complex_script', script_filename] + else: + args += ['-filter_complex', filter_arg] args += reduce( operator.add, [_get_output_args(node, stream_name_map) for node in output_nodes] ) @@ -174,7 +178,7 @@ def get_args(stream_spec, overwrite_output=False): @output_operator() -def compile(stream_spec, cmd='ffmpeg', overwrite_output=False): +def compile(stream_spec, cmd='ffmpeg', overwrite_output=False, script_filename=None): """Build command-line for invoking ffmpeg. The :meth:`run` function uses this to build the command line @@ -189,7 +193,7 @@ def compile(stream_spec, cmd='ffmpeg', overwrite_output=False): cmd = [cmd] elif type(cmd) != list: cmd = list(cmd) - return cmd + get_args(stream_spec, overwrite_output=overwrite_output) + return cmd + get_args(stream_spec, overwrite_output=overwrite_output, script_filename=script_filename) @output_operator()