-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_filtergraph_build.py
More file actions
84 lines (71 loc) · 3.44 KB
/
test_filtergraph_build.py
File metadata and controls
84 lines (71 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from ffmpegio import filtergraph as fgb, FFmpegioError
import pytest
@pytest.mark.parametrize(
"left,right, from_left, to_right, chain_siso, ret",
[
# fmt: off
("scale", "fps",(0,0,0),(0,0,0),True,'scale,fps'),
("scale", "fps",(0,0,0),(0,0,0),False,'[UNC0]scale[L0];[L0]fps[UNC1]'),
("split", "fps",(0,0,1),(0,0,0),True,'[UNC0]split[UNC1][L0];[L0]fps[UNC2]'),
("split", "vstack",[(0,0,0),(0,0,1)],[(0,0,1),(0,0,0)],True,'[UNC0]split[L0][L1];[L1][L0]vstack[UNC1]'),
("scale", "fps,eq",(0,0,0),(0,0,0),True,'scale,fps,eq'),
("scale,fps", "eq",(0,1,0),(0,0,0),True,'scale,fps,eq'),
("scale", "[0:v]vstack[out]",(0,0,0),(0,0,1),True,'[UNC0]scale,[0:v]vstack[out]'),
("scale", "[in1][0:v]vstack[out]",(0,0,0),(0,0,0),True,'[UNC0]scale[L0];[L0][0:v]vstack[out]'),
# fmt: on
],
)
def test_connect(left, right, from_left, to_right, chain_siso, ret):
fg = fgb.connect(left, right, from_left, to_right, chain_siso=chain_siso)
assert fg.compose() == ret
@pytest.mark.parametrize(
"left,right,how,n_links,strict,unlabeled_only,ret",
[
# fmt: off
("scale","fps",'all',0,False,False,'scale,fps'),
("scale","fps,eq",'all',0,False,False,'scale,fps,eq'),
("scale,fps","eq",'all',0,False,False,'scale,fps,eq'),
("split","vstack",'all',0,False,False,'[UNC0]split[L0][L1];[L0][L1]vstack[UNC1]'),
("split","vstack",'all',1,False,False,'[UNC0]split[L0][UNC2];[L0][UNC1]vstack[UNC3]'),
("[vin1]scale;[vin2]split","vstack[vout1];trim[vout2]",'all',0,False,False,'[vin1]scale[L0];[vin2]split[L1],trim[vout2];[L0][L1]vstack[vout1]'),
("[vin]scale;[ain]asplit","vstack[vout];atrim[aout]",'per_chain',0,False,False,'[vin]scale[L0];[ain]asplit[L1][UNC1];[L0][UNC0]vstack[vout];[L1]atrim[aout]'),
("[vin]scale;[ain]asplit","vstack[vout]",'all',0,False,False,'[vin]scale[L0];[ain]asplit[L1][UNC0];[L0][L1]vstack[vout]'),
("[vin]scale;[ain]asplit","vstack[vout]",'all',0,True,False,None),
("split[out]","[in]vstack",'all',0,False,True,'[UNC0]split[out],[in]vstack[UNC1]'),
# fmt: on
],
)
def test_join(left, right, how, n_links, strict, unlabeled_only, ret):
if ret is None:
with pytest.raises(FFmpegioError):
fgb.join(left, right, how, n_links, strict, unlabeled_only)
else:
fg = fgb.join(left, right, how, n_links, strict, unlabeled_only)
assert fg.compose() == ret
@pytest.mark.parametrize(
"left,right,left_on,right_on,ret",
[
# fmt: off
("scale", "fps", (0, 0, 0), (0, 0, 0), "scale,fps"),
("scale", "fps", None, None, "scale,fps"),
("scale", "[out]", None, None, "[UNC0]scale[out]"),
("[in]", "scale", None, None, "[in]scale[UNC0]"),
("[in]split", ["fps", "out"], None, None, "[in]split[L0][out];[L0]fps[UNC0]"),
(["in", "fps"], "vstack", None, None, "[UNC0]fps[L0];[in][L0]vstack[UNC1]"),
# fmt: on
],
)
def test_attach(left, right, left_on, right_on, ret):
if ret is None:
with pytest.raises(ValueError):
fgb.attach(left, right, left_on, right_on)
else:
fg = fgb.attach(left, right, left_on, right_on)
assert fg.compose() == ret
def test_join_bug():
af1 = fgb.Chain("aevalsrc,aformat")
af2 = fgb.Graph("channelmap,bandpass,aresample")
af3 = fgb.Chain("channelmap,bandpass,aresample")
af_a = af1 + af2
af_b = af1 + af3
assert af_a==af_b