8000 Merge pull request #46 from Depaulicious/asplit_filter · Powercoder64/ffmpeg-python@a029d7a · GitHub
[go: up one dir, main page]

Skip to content

Commit a029d7a

Browse files
authored
Merge pull request kkroening#46 from Depaulicious/asplit_filter
Add `asplit` filter
2 parents 6ebda44 + c87fd5c commit a029d7a

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

ffmpeg/_filters.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def split(stream):
5252
return FilterNode(stream, split.__name__)
5353

5454

55+
@filter_operator()
56+
def asplit(stream):
57+
return FilterNode(stream, asplit.__name__)
58+
59+
5560
@filter_operator()
5661
def setpts(stream, expr):
5762
"""Change the PTS (presentation timestamp) of the input frames.

ffmpeg/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __init__(self, stream_spec, name, max_inputs=1, args=[], kwargs={}):
152152
def _get_filter(self, outgoing_edges):
153153
args = self.args
154154
kwargs = self.kwargs
155-
if self.name == 'split':
155+
if self.name in ('split', 'asplit'):
156156
args = [len(outgoing_edges)]
157157

158158
out_args = [escape_chars(x, '\\\'=:') for x in args]

ffmpeg/tests/test_ffmpeg.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,41 @@ def test_get_args_complex_filter():
147147
]
148148

149149

150+
def _get_complex_filter_asplit_example():
151+
split = (ffmpeg
152+
.input(TEST_INPUT_FILE1)
153+
.vflip()
154+
.asplit()
155+
)
156+
split0 = split[0]
157+
split1 = split[1]
158+
159+
return (ffmpeg
160+
.concat(
161+
split0.filter_("atrim", start=10, end=20),
162+
split1.filter_("atrim", start=30, end=40),
163+
)
164+
.output(TEST_OUTPUT_FILE1)
165+
.overwrite_output()
166+
)
167+
168+
169+
def test_filter_asplit():
170+
out = _get_complex_filter_asplit_example()
171+
args = out.get_args()
172+
assert args == [
173+
'-i',
174+
TEST_INPUT_FILE1,
175+
'-filter_complex',
176+
'[0]vflip[s0];[s0]asplit=2[s1][s2];[s1]atrim=end=20:start=10[s3];[s2]atrim=end=40:start=30[s4];[s3]'
177+
'[s4]concat=n=2[s5]',
178+
'-map',
179+
'[s5]',
180+
TEST_OUTPUT_FILE1,
181+
'-y'
182+
]
183+
184+
150185
def test_filter_normal_arg_escape():
151186
"""Test string escaping of normal filter args (e.g. ``font`` param of ``drawtext`` filter)."""
152187
def _get_drawtext_font_repr(font):

0 commit comments

Comments
 (0)
0