mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-04-05 20:11:11 +08:00
#17: auto-generate split output count
This commit is contained in:
parent
5d78a2595d
commit
cf1b7bfd4b
@ -59,7 +59,7 @@ def _get_filter_spec(node, outgoing_edge_map, stream_name_map):
|
||||
outgoing_edges = get_outgoing_edges(node, outgoing_edge_map)
|
||||
inputs = [stream_name_map[edge.upstream_node, edge.upstream_label] for edge in incoming_edges]
|
||||
outputs = [stream_name_map[edge.upstream_node, edge.upstream_label] for edge in outgoing_edges]
|
||||
filter_spec = '{}{}{}'.format(''.join(inputs), node._get_filter(), ''.join(outputs))
|
||||
filter_spec = '{}{}{}'.format(''.join(inputs), node._get_filter(outgoing_edges), ''.join(outputs))
|
||||
return filter_spec
|
||||
|
||||
|
||||
|
@ -148,11 +148,17 @@ class FilterNode(Node):
|
||||
kwargs=kwargs
|
||||
)
|
||||
|
||||
def _get_filter(self):
|
||||
params_text = self.name
|
||||
arg_params = ['{}'.format(arg) for arg in self.args]
|
||||
kwarg_params = ['{}={}'.format(k, self.kwargs[k]) for k in sorted(self.kwargs)]
|
||||
def _get_filter(self, outgoing_edges):
|
||||
args = self.args
|
||||
kwargs = self.kwargs
|
||||
if self.name == 'split':
|
||||
args = [len(outgoing_edges)]
|
||||
|
||||
arg_params = ['{}'.format(arg) for arg in args]
|
||||
kwarg_params = ['{}={}'.format(k, kwargs[k]) for k in sorted(kwargs)]
|
||||
params = arg_params + kwarg_params
|
||||
|
||||
params_text = self.name
|
||||
if params:
|
||||
params_text += '={}'.format(':'.join(params))
|
||||
return params_text
|
||||
|
@ -122,7 +122,7 @@ def test_get_args_complex_filter():
|
||||
'-i', TEST_OVERLAY_FILE,
|
||||
'-filter_complex',
|
||||
'[0]vflip[s0];' \
|
||||
'[s0]split[s1][s2];' \
|
||||
'[s0]split=2[s1][s2];' \
|
||||
'[s1]trim=end_frame=20:start_frame=10[s3];' \
|
||||
'[s2]trim=end_frame=40:start_frame=30[s4];' \
|
||||
'[s3][s4]concat=n=2[s5];' \
|
||||
|
Loading…
x
Reference in New Issue
Block a user