-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_avistreams.py
More file actions
86 lines (72 loc) · 2.65 KB
/
test_avistreams.py
File metadata and controls
86 lines (72 loc) · 2.65 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
85
86
from ffmpegio.streams import AviStreams
from ffmpegio import open
def test_open():
url1 = "tests/assets/testvideo-1m.mp4"
url2 = "tests/assets/testaudio-1m.mp3"
with open((url1, url2), "rav", t=1, blocksize=0) as reader:
for st, data in reader:
print(st, data['shape'], data['dtype'])
print('testing "rvv"')
with open(
url1,
"rvv",
t=1,
blocksize=0,
filter_complex="[0:v]split=2[out1][out2]",
map=["[out1]", "[out2]"],
) as reader:
for st, data in reader:
print(st, data['shape'], data['dtype'])
print('testing "raa"')
with open(
url2,
"raa",
t=1,
blocksize=0,
filter_complex="[0:a]asplit=2[out1][out2]",
map=["[out1]", "[out2]"],
) as reader:
for st, data in reader:
print(st, data['shape'], data['dtype'])
# print(reader.readlog())
def test_avireadstream():
url1 = "tests/assets/testvideo-1m.mp4"
url2 = "tests/assets/testaudio-1m.mp3"
with AviStreams.AviMediaReader(url1, url2, t=1, blocksize=0) as reader:
for st, data in reader:
print(st, data['shape'], data['dtype'])
with AviStreams.AviMediaReader(url1, url2, t=1, blocksize=1) as reader:
for data in reader:
print({k: (v['shape'], v['dtype']) for k, v in data.items()})
with AviStreams.AviMediaReader(
url1, url2, t=1, blocksize=1000, ref_stream="a:0"
) as reader:
for data in reader:
print({k: (v['shape'], v['dtype']) for k, v in data.items()})
with AviStreams.AviMediaReader(url1, url2, t=1) as reader:
print(reader.specs())
print(reader.types())
print(reader.rates())
print(reader.dtypes())
print(reader.shapes())
print(reader.get_stream_info("v:0"))
print(reader.get_stream_info("a:0"))
data = reader.readall()
print({k: (v['shape'], v['dtype']) for k, v in data.items()})
if __name__ == "__main__":
url = "tests/assets/testmulti-1m.mp4"
url1 = "tests/assets/testvideo-1m.mp4"
url2 = "tests/assets/testaudio-1m.mp3"
from pprint import pprint
with AviStreams.AviMediaReader(url1, url2, t=1) as reader:
reader._reader.wait()
print(f'thread is running {reader._reader.is_alive()}')
pprint(reader.specs())
print(reader.types())
print(reader.rates())
print(reader.dtypes())
print(reader.shapes())
print(reader.get_stream_info("v:0"))
print(reader.get_stream_info("a:0"))
data = reader.readall()
print({k: (v['shape'], v['dtype']) for k, v in data.items()})