siili
unknown
python
2 years ago
2.0 kB
12
Indexable
import sys
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
print('Looking for sources containing "Siili" in their name...')
while True:
ndi.find_wait_for_sources(ndi_find, 1000)
sources = ndi.find_get_current_sources(ndi_find)
siili_sources = [s for s in sources if "SIILI" in s.ndi_name]
if siili_sources:
break
else:
print('No "Siili" sources found, retrying...')
# Display the filtered sources and ask the user to select one
print("\nFound 'Siili' sources:")
for i, source in enumerate(siili_sources, start=1):
print(f"{i}. {source.ndi_name}")
selection = int(input("Select a source (number): ")) - 1
selected_source = siili_sources[selection]
# Create an NDI receiver
ndi_recv_create = ndi.RecvCreateV3()
ndi_recv_create.color_format = ndi.RECV_COLOR_FORMAT_BGRX_BGRA
ndi_recv = ndi.recv_create_v3(ndi_recv_create)
if ndi_recv is None:
return 0
# Connect to the selected source
ndi.recv_connect(ndi_recv, selected_source)
ndi.find_destroy(ndi_find)
# Rest of your code for receiving data...
while True:
t, v, a, _ = ndi.recv_capture_v2(ndi_recv, 5000)
endstring = ""
if t == ndi.FRAME_TYPE_NONE:
print('No data received.')
if t == ndi.FRAME_TYPE_VIDEO:
print('Video data received (%dx%d).d' % (v.xres, v.yres))
ndi.recv_free_video_v2(ndi_recv, v)
if t == ndi.FRAME_TYPE_AUDIO:
#print('Audio data received (%d samples).' % a.no_samples)
ndi.recv_free_audio_v2(ndi_recv, a)
inp = input("exit to enter 1")
if inp == "1":
break
ndi.recv_destroy(ndi_recv)
ndi.destroy()
return 0
if __name__ == "__main__":
sys.exit(main())
Editor is loading...
Leave a Comment