cyndilib.video_frame

VideoFrame

class cyndilib.video_frame.VideoFrame

Bases: object

Base class for video frames

bits_per_pixel

Bits per pixel for the current fourcc

Added in version 0.0.5.

fourcc

The current FourCC format type

frame_format

FrameFormat

The current FrameFormat type

Added in version 0.1.1.

Type:

frame_format

get_buffer_size(self)
get_data_size(self) int
get_format_string(self) str

Get the video format as a string based off of resolution, frame rate and field format (“1080i59.94”, etc)

get_fourcc(self)

Get the FourCC format type

get_frame_rate(self) Fraction

Get the video frame rate

get_line_stride(self)
get_resolution(self)

Get the video resolution as a tuple of (width, height)

get_timecode_posix(self)

Get the current timecode converted to float seconds (posix)

get_timestamp_posix(self)

Get the current timestamp converted to float seconds (posix)

is_progressive

bool

True if the current frame_format is progressive, False if interlaced

Added in version 0.1.1.

Type:

is_progressive

padded_bits_per_pixel

Padded bits per pixel for the current fourcc

Added in version 0.0.5.

padded_bytes_per_line

Padded bytes per line for the current fourcc

Added in version 0.0.6.

set_fourcc(self, value: FourCC)

Set the FourCC format type

set_frame_format(self, fmt: FrameFormat) None

Set the FrameFormat type

Added in version 0.1.1.

set_frame_rate(self, value: Fraction)

Set the video frame rate

set_metadata(self, metadata: bytes)

Set the metadata for the video frame

Added in version 0.0.6.

set_progressive(self, value: bool) None

Set whether the video frame is progressive or interlaced

Note

Setting this to False will set the frame_format to interleaved which indicates that the frame is a fielded, but complete frame (comprised of both fields).

If you want to specify individual fields, you should set the frame_format directly to field_0 or field_1 using the set_frame_format() method.

Parameters:

value (bool) – If True, set to progressive. If False, set to interlaced.

Added in version 0.1.1.

set_resolution(self, xres: int, yres: int)

Set the video resolution

xres

X resolution (width)

yres

Y resolution (height)

VideoRecvFrame

class cyndilib.video_frame.VideoRecvFrame

Bases: VideoFrame

Video frame to be used with a receiver.Receiver

Parameters:

max_buffers (int, optional) – The maximum number of items to store in the buffer. Defaults to 4

Incoming data from the receiver is placed into temporary buffers so it can be read without possibly losing frames.

The buffer items retain both the frame data and corresponding timestamps. They can be read using the fill_p_data() method or using the buffer protocol.

buffer_full(self) bool

Returns True if the buffers are all in use

fill_p_data(self, dest: uint8_t[:])

Copy the first buffered frame data into the given destination array (or memoryview).

The array should be typed as unsigned 8-bit integers sized to match that of get_buffer_size()

get_buffer_depth(self) int

Get the number of buffered frames

get_view_count(self)
skip_frames(self, eager: bool)

Discard buffered frame(s)

If the buffers remain full and the application can’t keep up, this can be used as a last resort.

Parameters:

eager (bool) – If True, discard all buffered frames except one (the most recently received). If False, only discard one frame

Returns the number of frames skipped

VideoFrameSync

class cyndilib.video_frame.VideoFrameSync

Bases: VideoFrame

Video frame for use with framesync.FrameSync

Unlike VideoRecvFrame, this object does not store or buffer any data. It will always contain the most recent video frame data after a call to framesync.FrameSync.capture_video().

This is by design since the FrameSync methods utilize buffering from within the NDI® library.

Data can be read using the get_array() method or by using the buffer protocol.

get_array(self)

Get the video frame data as an numpy.ndarray of unsigned 8-bit integers

VideoSendFrame

class cyndilib.video_frame.VideoSendFrame

Bases: VideoFrame

Video frame for use with sender.Sender

Note

Instances of this class are not intended to be created directly nor are its methods. They are instead called from the sender.Sender write methods.

destroy(self)
get_write_available(self)
write_data(self, data: uint8_t[:])

Write a frame of video data to the internal buffer

The buffered data will then be sent on the next call to sender.Sender.send_video() or sender.Sender.send_video_async()

Parameters:

data – A 1-d array or memoryview of unsigned 8-bit integers formatted as described in wrapper.ndi_structs.FourCC

Note

This method is available for flexibility, but using sender.Sender.write_video() or sender.Sender.write_video_async() may be more desirable as the video data will be buffered and sent immediately