Skip to content

Commit d49fffa

Browse files
committed
Graph.join - added how="auto"
1 parent 60996e6 commit d49fffa

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

src/ffmpegio/filtergraph.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,15 +1381,15 @@ def __add__(self, other):
13811381
other = as_filtergraph_object(other)
13821382
except Exception:
13831383
return NotImplemented
1384-
return self.join(other)
1384+
return self.join(other, "auto")
13851385

13861386
def __radd__(self, other):
13871387
# join
13881388
try:
13891389
other = as_filtergraph(other)
13901390
except Exception:
13911391
return NotImplemented
1392-
return other.join(self)
1392+
return other.join(self, "auto")
13931393

13941394
def __or__(self, other):
13951395
# create filtergraph with self and other as parallel chains, self first
@@ -2224,12 +2224,7 @@ def join(
22242224
:type right: Graph|Chain|Filter
22252225
:param how: method on how to mate input and output, defaults to "per_chain".
22262226
2227-
----------- -------------------------------------------------------------------
2228-
'chainable' joins only chainable input pads and output pads.
2229-
'per_chain' |joins one pair of first available input pad and output pad of each
2230-
|mating chains. Source and sink chains are ignored.
2231-
'all' joins all input pads and output pads
2232-
----------- -------------------------------------------------------------------
2227+
'auto' tries 'per_chain' first, if fails, then tries 'all'.
22332228
22342229
:type how: "chainable"|"per_chain"|"all"
22352230
:param match_scalar: True to multiply self if SO-MI connection or right if MO-SI connection
@@ -2252,6 +2247,27 @@ def join(
22522247
if not len(self):
22532248
return Graph(right)
22542249

2250+
# auto-mode, 1-deep recursion
2251+
if how == "auto":
2252+
try:
2253+
return self.join(
2254+
right,
2255+
"per_chain",
2256+
match_scalar,
2257+
ignore_labels,
2258+
chain_siso,
2259+
replace_sws_flags,
2260+
)
2261+
except:
2262+
return self.join(
2263+
right,
2264+
"all",
2265+
match_scalar,
2266+
ignore_labels,
2267+
chain_siso,
2268+
replace_sws_flags,
2269+
)
2270+
22552271
# list all the unconnected output pads of left fg
22562272
# [(index, label, filter)]
22572273
src_info = tuple(self._iter_io_pads(False, how, ignore_labels))

0 commit comments

Comments
 (0)