-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathrecv_framesync.py
More file actions
52 lines (34 loc) · 1.06 KB
/
recv_framesync.py
File metadata and controls
52 lines (34 loc) · 1.06 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
import sys
import time
import numpy as np
import NDIlib as ndi
def main():
if not ndi.initialize():
return 0
ndi_find = ndi.find_create_v2()
if ndi_find is None:
return 0
sources = []
while not len(sources) > 0:
print('Looking for sources ...')
ndi.find_wait_for_sources(ndi_find, 1000)
sources = ndi.find_get_current_sources(ndi_find)
ndi_recv = ndi.recv_create_v3()
if ndi_recv is None:
return 0
ndi.recv_connect(ndi_recv, sources[0])
ndi_framesync = ndi.framesync_create(ndi_recv)
ndi.find_destroy(ndi_find)
t = time.time()
while time.time() - t < 5.0 * 60:
v = ndi.framesync_capture_video(ndi_framesync)
ndi.framesync_free_video(ndi_framesync, v)
a = ndi.framesync_capture_audio(ndi_framesync, 48000, 4, 1600)
ndi.framesync_free_audio(ndi_framesync, a)
time.sleep(33/1000)
ndi.framesync_destroy(ndi_framesync)
ndi.recv_destroy(ndi_recv)
ndi.destroy()
return 0
if __name__ == "__main__":
sys.exit(main())