cyndilib.receiver#
Receiver#
- class cyndilib.receiver.Receiver#
Bases:
objectA receiver for NDI® streams
- Parameters:
source_name (str, optional) – The NDI® source name to connect to. An empty string (default) indicates no source
source (Source, optional) – A
Sourceobject to connect to.None(default) indices no source.color_format – The
RecvColorFormatto acceptbandwidth – The
RecvBandwidthto useallow_video_fields –
Trueif interlaced video frames can be handled. IfFalse, only progressive frames will be delivered.recv_name – Name for the receiver
- video_frame#
- Type:
- audio_frame#
- Type:
- metadata_frame#
- Type:
- connect_to(self, src: Source)#
Alias for
set_source()
- get_num_connections(self)#
- get_performance_data(self)#
- is_connected(self)#
Returns True if currently connected
- is_ptz_supported(self)#
Returns True if the source accepts PTZ commands
New in version 0.0.7.
- preview_tally#
Indicates the preview tally state as set by
set_source_tally_program()
- program_tally#
Indicates the program tally state as set by
set_source_tally_program()
- receive(self, recv_type: ReceiveFrameType, timeout_ms: int) ReceiveFrameType#
Receive frame data of the given type
If requesting a video or audio frame and the result indicates data was received, the incoming frame data will be available in the
video_frameoraudio_frame.- Parameters:
recv_type (ReceiveFrameType) – The frame type(s) to receive
timeout_ms (int) – Time (in milliseconds) to wait for a frame to be available
Returns a
ReceiveFrameTypeindicating what was received. If nothing was available before the timeout, the result will beReceiveFrameType.nothing
- reconnect(self)#
- set_audio_frame(self, af: AudioRecvFrame)#
Set the
audio_frame
- set_metadata_frame(self, mf: MetadataRecvFrame)#
Set the
metadata_frame
- set_source(self, src: Source)#
Set the current
sourceIf the source is None, disconnects if necessary. Otherwise, attempt to connect to it.
- set_source_tally_preview(self, value: bool)#
Set the preview tally state for the currently connected source
See notes in the
set_source_tally_program()method
- set_source_tally_program(self, value: bool)#
Set the program tally state for the currently connected source.
This method sends a tally command to the source and does not necessarily affect the state of the
sourceobject’s tally. It will be updated independently when tally metadata is received.This is because other receivers may have also sent tally messages to the source. When this occurs, the source’s tally remains “on” until all of its connected receivers have set it to “off” (like a bitwise “OR”)
- set_video_frame(self, vf: VideoRecvFrame)#
Set the
video_frame
PTZ#
- class cyndilib.receiver.PTZ#
Bases:
objectPTZ control for a
Receiver- autofocus(self)#
Re-enables / triggers the autofocus.
New in version 0.0.7.
- exposure_auto(self)#
(Re-)enables the auto exposure mode.
New in version 0.0.7.
- focus(self, focus_speed: float)#
Controls the focus of the camera.
The assumption is that this function is called continuously, for example while pressing a button in a GUI or HID.
>>> for _ in range(0, 100): ... time.sleep(0.05) ... receiver.ptz.focus(.5)
- Parameters:
focus_speed (float) – -1.0 (focus out) … 0.0 (no change) … 1.0 (focus in)
New in version 0.0.7.
- pan(self, pan_speed: float)#
Pan the camera.
The assumption is that this function is called continuously, for example while pressing a button in a GUI or HID.
>>> for _ in range(0, 100): ... time.sleep(0.05) ... receiver.ptz.pan(.5)
- Parameters:
pan_speed (float) – 1.0 (fastest left) … 0.0 (no movement) … -1.0 (fastest right)
This is the same as pan_and_tilt(pan_speed, 0.0), see
pan_and_tilt().New in version 0.0.7.
- pan_and_tilt(self, pan_speed: float, tilt_speed: float)#
Pan and tilt the camera.
The assumption is that this function is called continuously, for example while pressing a button in a GUI or HID.
>>> for _ in range(0, 100): ... time.sleep(0.05) ... receiver.ptz.pan_and_tilt(.5)
- Parameters:
Attention
1 is to the left, and -1 is to the right!
New in version 0.0.7.
- recall_preset(self, preset_no: int, speed: float)#
Recalls a previously stored PTZ preset.
This includes position, focus, …. The speed indicates how fast the camera moves to the position.
New in version 0.0.7.
- set_exposure_coarse(self, exposure_level: float)#
Manually control the exposure.
See also
set_exposure_fine().- Parameters:
exposure_level (float) – 0.0 (dark) … 1.0 (bright)
Note
Use either this or
set_exposure_fine(). There’s no value in using both. Preferset_exposure_fine().New in version 0.0.7.
- set_exposure_fine(self, iris: float, gain: float, shutter_speed: float)#
Precisely control the exposure.
See also
set_exposure_coarse().- Parameters:
Note
Use either this or
set_exposure_coarse(). There’s no value in using both. Prefer this method.New in version 0.0.7.
- set_focus(self, focus_value: float)#
Sets focus to a specific value.
- Parameters:
focus_value (float) – 0.0 (max focus out; infinity) … 1.0 (max focus in)
New in version 0.0.7.
- set_pan_and_tilt_values(self, pan_value: float, tilt_value: float)#
Set pan and tilt angles of the camera.
- Parameters:
Note
Some cameras (e.g. OBSBOT) only support tilt values from -0.5 to 0.5.
New in version 0.0.7.
- set_white_balance(self, red: float, blue: float)#
Manually set the white balance values.
New in version 0.0.7.
- set_zoom_level(self, zoom_level: float)#
Set the PTZ zoom level
- Parameters:
zoom_level (float) – 0.0 (max zoomed out) … 1.0 (max zoomed in)
New in version 0.0.7.
- store_preset(self, preset_no: int)#
Store the current PTZ configuration as preset.
This includes position, focus, ….
- Parameters:
preset_no (int) – 0 … 99
New in version 0.0.7.
- tilt(self, tilt_speed: float)#
Pan and tilt the camera.
The assumption is that this function is called continuously, for example while pressing a button in a GUI or HID.
>>> for _ in range(0, 100): ... time.sleep(0.05) ... receiver.ptz.tilt(.5)
- Parameters:
tilt_speed (float) – -1.0 (fastest downwards) … 0.0 (no movement) … 1.0 (fastest upwards)
This is the same as pan_and_tilt(0.0, tilt_speed), see
pan_and_tilt().New in version 0.0.7.
- white_balance_auto(self)#
Changes the white balance to auto mode.
New in version 0.0.7.
- white_balance_indoor(self)#
Changes the white balance to indoor mode.
New in version 0.0.7.
- white_balance_oneshot(self)#
Determines the white balance automatically from the center of the current frame.
New in version 0.0.7.
- white_balance_outdoor(self)#
Changes the white balance to outdoor mode.
New in version 0.0.7.
- zoom(self, zoom_speed: float)#
Zoom the camera with the given speed.
The assumption is that this function is called continuously, for example while pressing a button in a GUI or HID.
>>> for _ in range(0, 100): ... time.sleep(0.05) ... receiver.ptz.zoom(.5)
- Parameters:
zoom_speed (float) – -1.0 (zoom out, max speed) … 0.0 (no zooming) … 1.0 (zoom in, max speed)
New in version 0.0.7.
RecvThread#
- class cyndilib.receiver.RecvThread(receiver, timeout_ms, recv_frame_type=7, wait_time=0.1)#
Bases:
ThreadA thread designed for use with
ReceiverRepeatedly calls
Receiver.receive()using the supplied arguments. A callback is then triggered whenever new frames are received.This can be used to handle video and audio using two separate threads. One thread would be set to use
recv_videoand the other torecv_audio.- Parameters:
receiver (Receiver) – The receiver instance
timeout_ms (int) – Timeout (in milliseconds) to use when calling
Receiver.receive()recv_frame_type (ReceiveFrameType) – The type(s) of frames to receive
wait_time (float) – Amount of time (in seconds) to sleep between calls to
Receiver.receive()
- run(self)#
- set_callback(self, cb)#
Set the callback used to indicate new frames
- set_wait_event(self)#
- stop(self)#
Stop the thread
ReceiveFrameType#
- class cyndilib.receiver.ReceiveFrameType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
IntFlagFrame type flags used to receive specific frame types and indicate results. Members and be combined using bit-wise operators.
- nothing#
Indicate nothing can or has been received
- recv_video#
Indicate video frames can or have been received
- recv_audio#
Indicate video frames can or have been received
- recv_metadata#
Indicate metadata frames can or have been received
- recv_status_change#
Indicate a status change has occurred (results only)
- recv_error#
Indicate an error occurred (results only)
- recv_buffers_full#
Indicates a
VideoRecvFrameorAudioRecvFramebuffer was full when trying to read (results only)
- recv_all#
A combination of
recv_video,recv_audioandrecv_metadata