spdl.io.VideoFrames

class VideoFrames[source]

Video frames.

Methods

clone()

Clone the frames, so that data can be converted to buffer multiple times.

Attributes

height

The height of video.

num_frames

The number of video frames.

num_planes

The number of planes in the each frame.

pix_fmt

The name of the pixel format.

width

The width of video.

__getitem__(key: int) ImageFrames[source]
__getitem__(key: slice) VideoFrames
__getitem__(key: list[int]) VideoFrames

Slice frame by key.

Parameters:

key – If the key is int type, a single frame is returned as ImageFrames. If the key is slice type, a new VideoFrames object pointing the corresponding frames are returned.

Returns:

The sliced frame.

__len__() int[source]

Returns the number of frames. Same as num_frames.

clone() VideoFrames[source]

Clone the frames, so that data can be converted to buffer multiple times.

Returns:

A clone of the frame.

property height: int[source]

The height of video.

property num_frames: int[source]

The number of video frames. Same as __len__ method.

property num_planes: int[source]

The number of planes in the each frame.

Note

This corresponds to the number of color components, however it does not always match with the number of color channels when the frame is converted to buffer/array object.

For example, if a video file is YUV format (which is one of the most common formats, and comprised of different plane sizes), and color space conversion is disabled during the decoding, then the resulting frames are converted to buffer as single channel frame where all the Y, U, V components are packed.

SPDL by default converts the color space to RGB, so this is usually not an issue.

property pix_fmt: str[source]

The name of the pixel format.

property width: int[source]

The width of video.