10000 Add `asplit` filter by depau · Pull Request #46 · kkroening/ffmpeg-python · GitHub
[go: up one dir, main page]

Skip to content
8000

Add asplit filter #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ffmpeg/_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def split(stream):
return FilterNode(stream, split.__name__)


@filter_operator()
def asplit(stream):
return FilterNode(stream, asplit.__name__)


@filter_operator()
def setpts(stream, expr):
"""Change the PTS (presentation timestamp) of the input frames.
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, stream_spec, name, max_inputs=1, args=[], kwargs={}):
def _get_filter(self, outgoing_edges):
args = self.args
kwargs = self.kwargs
if self.name == 'split':
if self.name in ('split', 'asplit'):
args = [len(outgoing_edges)]

out_args = [escape_chars(x, '\\\'=:') for x in args]
Expand Down
35 changes: 35 additions & 0 deletions ffmpeg/tests/test_ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,41 @@ def test_get_args_complex_filter():
]


def _get_complex_filter_asplit_example():
split = (ffmpeg
.input(TEST_INPUT_FILE1)
.vflip()
.asplit()
)
split0 = split[0]
split1 = split[1]

return (ffmpeg
.concat(
split0.filter_("atrim", start=10, end=20),
split1.filter_("atrim", start=30, end=40),
)
.output(TEST_OUTPUT_FILE1)
.overwrite_output()
)


def test_filter_asplit():
out = _get_complex_filter_asplit_example()
args = out.get_args()
assert args == [
'-i',
TEST_INPUT_FILE1,
'-filter_complex',
'[0]vflip[s0];[s0]asplit=2[s1][s2];[s1]atrim=end=20:start=10[s3];[s2]atrim=end=40:start=30[s4];[s3]'
'[s4]concat=n=2[s5]',
'-map',
'[s5]',
TEST_OUTPUT_FILE1,
'-y'
]


def test_filter_normal_arg_escape():
"""Test string escaping of normal filter args (e.g. ``font`` param of ``drawtext`` filter)."""
def _get_drawtext_font_repr(font):
Expand Down
0