mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-08-07 18:39:47 +08:00
Start fixing escaping for pan filter (which uses |
)
This commit is contained in:
parent
e5003648bb
commit
0a5c5c2877
@ -148,22 +148,31 @@ class FilterNode(Node):
|
||||
kwargs=kwargs
|
||||
)
|
||||
|
||||
"""FilterNode"""
|
||||
def _get_filter(self, outgoing_edges):
|
||||
args = self.args
|
||||
kwargs = self.kwargs
|
||||
if self.name == 'split':
|
||||
args = [len(outgoing_edges)]
|
||||
@classmethod
|
||||
def _get_item_param(cls, item):
|
||||
return escape_chars(item, '\\\'=:')
|
||||
|
||||
out_args = [escape_chars(x, '\\\'=:') for x in args]
|
||||
@classmethod
|
||||
def _get_dict_params(cls, d):
|
||||
out_kwargs = {}
|
||||
for k, v in list(kwargs.items()):
|
||||
for k, v in list(d.items()):
|
||||
k = escape_chars(k, '\\\'=:')
|
||||
v = escape_chars(v, '\\\'=:')
|
||||
out_kwargs[k] = v
|
||||
return ['{}={}'.format(k, out_kwargs[k]) for k in sorted(out_kwargs)]
|
||||
|
||||
arg_params = [escape_chars(v, '\\\'=:') for v in out_args]
|
||||
kwarg_params = ['{}={}'.format(k, out_kwargs[k]) for k in sorted(out_kwargs)]
|
||||
@classmethod
|
||||
def _get_list_params(cls, l):
|
||||
out_args = [cls._get_item_param(x) for x in l]
|
||||
return [escape_chars(v, '\\\'=:') for v in out_args]
|
||||
|
||||
def _get_filter(self, outgoing_edges):
|
||||
args = self.args
|
||||
if self.name == 'split':
|
||||
args = [len(outgoing_edges)]
|
||||
|
||||
arg_params = self._get_list_params(args)
|
||||
kwarg_params = self._get_dict_params(self.kwargs)
|
||||
params = arg_params + kwarg_params
|
||||
|
||||
params_text = escape_chars(self.name, '\\\'=:')
|
||||
|
@ -265,6 +265,18 @@ def test_custom_filter():
|
||||
]
|
||||
|
||||
|
||||
def test_custom_filter_escaped():
|
||||
stream = ffmpeg.input('dummy.mp4')
|
||||
stream = ffmpeg.filter_(stream, 'bogus=stuff', 'a=b\'', **{'c\\d': 'e=f'})
|
||||
stream = ffmpeg.output(stream, 'dummy2.mp4')
|
||||
assert stream.get_args() == [
|
||||
'-i', 'dummy.mp4',
|
||||
'-filter_complex', '[0]bogus\\\\=stuff=a\\\\\\\\\\\\=b\\\\\\\\\\\\\\\':c\\\\\\\\d=e\\\\=f[s0]',
|
||||
'-map', '[s0]',
|
||||
'dummy2.mp4'
|
||||
]
|
||||
|
||||
|
||||
def test_custom_filter_fluent():
|
||||
stream = (ffmpeg
|
||||
.input('dummy.mp4')
|
||||
|
Loading…
x
Reference in New Issue
Block a user