-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_parallel.py
More file actions
42 lines (33 loc) · 1.1 KB
/
test_parallel.py
File metadata and controls
42 lines (33 loc) · 1.1 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
"""Test to process input streams into an output stream in parallel"""
from stream_input import InputStream, InputQueue
from stream_output import OutputStream
def finished_in(filename: str):
"""dummy callback for the input stream finished event"""
print(f"\n\n\nfinished input {filename}\n\n\n")
# call backs should also provide a frame number?
def finished_out(filename: str):
"""dummy callback for the output stream finished event"""
print(f"\n\n\nfinished output {filename}\n\n\n")
input_queue = InputQueue("raw-video/dock*")
input1 = InputStream(input_queue, finished_in)
input2 = InputStream(input_queue, finished_in)
output_stream = OutputStream(
{
"output_template": "video/test.mp4",
"output_seconds": 60,
},
input1.attributes, # We need to make sure both streams match!
finished_out,
)
while True:
raw_bytes = input1.read()
if len(raw_bytes) == 0:
break
output_stream.write(raw_bytes)
raw_bytes = input2.read()
if len(raw_bytes) == 0:
break
output_stream.write(raw_bytes)
output_stream.close()
input2.close()
input1.close()