From f0ea9614cdbf75d3c92c163274366030d6046082 Mon Sep 17 00:00:00 2001 From: Davide Depau Date: Mon, 10 Jul 2017 20:06:37 +0200 Subject: [PATCH 1/2] add splits positional argument to specify the number of split nodes --- ffmpeg/_filters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffmpeg/_filters.py b/ffmpeg/_filters.py index a422f00..c269bbe 100644 --- a/ffmpeg/_filters.py +++ b/ffmpeg/_filters.py @@ -50,8 +50,8 @@ def filter_(stream_spec, filter_name, *args, **kwargs): @filter_operator() -def split(stream): - return FilterNode(stream, split.__name__) +def split(stream, splits=None): + return FilterNode(stream, split.__name__, args=[splits] if splits else [],) @filter_operator() From e8c51f2b20678c59f9dffdea7ec93cc652b4dc72 Mon Sep 17 00:00:00 2001 From: Davide Depau Date: Mon, 10 Jul 2017 20:28:07 +0200 Subject: [PATCH 2/2] Split exception should be a warning * we can't be 100% sure we're wrong and the user is right --- ffmpeg/_run.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ffmpeg/_run.py b/ffmpeg/_run.py index 83117e4..3495bbd 100644 --- a/ffmpeg/_run.py +++ b/ffmpeg/_run.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals +import warnings + from .dag import get_outgoing_edges, topo_sort from functools import reduce from past.builtins import basestring @@ -70,8 +72,8 @@ def _allocate_filter_stream_names(filter_nodes, outgoing_edge_maps, stream_name_ for upstream_label, downstreams in outgoing_edge_map.items(): if len(downstreams) > 1: # TODO: automatically insert `splits` ahead of time via graph transformation. - raise ValueError('Encountered {} with multiple outgoing edges with same upstream label {!r}; a ' - '`split` filter is probably required'.format(upstream_node, upstream_label)) + warnings.warn('Encountered {} with multiple outgoing edges with same upstream label {!r}; a ' + '`split` filter is probably required'.format(upstream_node, upstream_label), RuntimeWarning) stream_name_map[upstream_node, upstream_label] = _get_stream_name('s{}'.format(stream_count)) stream_count += 1