From 2ea1bea636237bcb524678fe0714d52722066433 Mon Sep 17 00:00:00 2001 From: Naoto Kondo Date: Sun, 20 Mar 2022 15:05:30 +0900 Subject: [PATCH] add example for the recv framesync --- example/recv_framesync.py | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 example/recv_framesync.py diff --git a/example/recv_framesync.py b/example/recv_framesync.py new file mode 100644 index 0000000..30a1127 --- /dev/null +++ b/example/recv_framesync.py @@ -0,0 +1,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_destoroy(ndi_framesync) + + ndi.recv_destroy(ndi_recv) + + ndi.destroy() + + return 0 + + +if __name__ == "__main__": + sys.exit(main())