spdl.io.VideoFrames

class VideoFrames

Video frames.

See Packets and Frames for information about the Frames base concept.

Attributes

clone

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

get_pts

Get the PTS (Presentation Time Stamp) in timebase unit.

get_timestamps

Get the timestamp of frames.

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.

time_base

Get the time base of PTS.

width

The width of video.

__getitem__

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__

Returns the number of frames. Same as num_frames.

clone

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

Returns:

A clone of the frame.

get_pts

Get the PTS (Presentation Time Stamp) in timebase unit.

get_timestamps

Get the timestamp of frames.

property height

The height of video.

property num_frames

The number of video frames. Same as __len__ method.

property num_planes

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

The name of the pixel format.

property time_base

Get the time base of PTS.

The time base is expressed as (Numerator, denominator).

PTS (in seconds) == PTS (in timebase unit) * Numerator / Denominator

property width

The width of video.