-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_plugins.py
More file actions
33 lines (26 loc) · 993 Bytes
/
test_plugins.py
File metadata and controls
33 lines (26 loc) · 993 Bytes
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
from ffmpegio.utils import prod
from ffmpegio import plugins
def test_rawdata_bytes():
hook = plugins.get_hook()
dtype = "|u1"
shape = (2, 2, 3)
b = b"\0" * prod(shape)
data = hook.bytes_to_video(b=b, dtype=dtype, shape=shape, squeeze=False)
assert data["buffer"] == b
assert data["dtype"] == dtype
assert data["shape"][1:] == shape
assert hook.video_info(obj=data) == (shape, dtype)
assert hook.video_bytes(obj=data) == b
data = hook.bytes_to_video(b=b, dtype=dtype, shape=shape, squeeze=True)
assert data["shape"] == shape
dtype = "<f4"
shape = (2,)
b = b"\0" * (1024 * prod(shape))
data = hook.bytes_to_audio(b=b, dtype=dtype, shape=shape, squeeze=False)
assert data["buffer"] == b
assert data["dtype"] == dtype
assert data["shape"][1:] == shape
assert hook.audio_info(obj=data) == (shape, dtype)
assert hook.audio_bytes(obj=data) == b
if __name__ == "__main__":
print(plugins.pm.get_plugins())