spdl.io.VideoPackets

class VideoPackets[source]

Packets object containing video frames.

Methods

clone()

Clone the packets, so that data can be decoded multiple times.

get_timestamps(*[, raw])

Get the timestamp of packets.

Attributes

codec

The codec.

frame_rate

The frame rate of the video in the form of (numerator, denominator).

height

The height of video.

pix_fmt

The name of the pixel format, such as "yuv420p".

timestamp

The window this packets covers, denoted by start and end time in second.

width

The width of video.

__len__() int[source]

Returns the number of packets.

Note

Each packet typically contains one compressed frame, but it is not guaranteed.

clone() VideoPackets[source]

Clone the packets, so that data can be decoded multiple times.

Returns:

A clone of the packets.

property codec: VideoCodec[source]

The codec.

property frame_rate: tuple[int, int][source]

The frame rate of the video in the form of (numerator, denominator).

get_timestamps(*, raw: bool = False) list[float][source]

Get the timestamp of packets.

By default, the returned timestamps are sorted by display time, and if user specified a time window when demuxing, the timestamps outside of the window is discatded.

Parameters:

raw

If True, the order of timestamps correspond to the order of packets, which is not necessarily ordered by display time. Also the user-specified window is not applied, so timestamps for all the packets are returned.

This option is mainly for debugging.

property height: int[source]

The height of video.

property pix_fmt: str[source]

The name of the pixel format, such as "yuv420p".

property timestamp: tuple[float, float] | None[source]

The window this packets covers, denoted by start and end time in second.

This is the value specified by user when demuxing the stream.

property width: int[source]

The width of video.