5.2.11. ytpb.representations

Representations from MPEG-DASH MPD.

class ytpb.representations.VideoQuality(height: int, frame_rate: float)

Bases: object

Represents a video quality (height and frame rate).

Examples

The class supports comparison operations. For example:

>>> VideoQuality(720) == VideoQuality(720, 30)
True
>>> VideoQuality(720) > VideoQuality(720, 60)
False
height: int
frame_rate: float
classmethod from_string(value: str) VideoQuality

Creates a VideoQuality object from string.

Parameters:

value – A video quality string. For example: “720p”, “1080p60”.

class ytpb.representations.RepresentationInfo(itag: str, mime_type: str, codecs: str, base_url: str)

Bases: object

Represents common attributes of audio and video representations.

itag: str

itag value, e.g. ‘140’, ‘247’.

mime_type: str

MIME type, e.g. ‘audio/mp4’, ‘video/webm’.

codecs: str

Codec name, e.g. ‘mp4’, ‘vp9’.

base_url: str

Segment base URL.

property type: str

An alias for a MIME type, e.g. ‘audio’, ‘video’.

property format: str

An alias for a MIME subtype, e.g. ‘mp4’, ‘webm’.

class ytpb.representations.AudioRepresentationInfo(itag: str, mime_type: str, codecs: str, base_url: str, audio_sampling_rate: int)

Bases: RepresentationInfo

Represents attributes of audio representations.

audio_sampling_rate: int

Sampling rate (in Hz).

itag: str

itag value, e.g. ‘140’, ‘247’.

mime_type: str

MIME type, e.g. ‘audio/mp4’, ‘video/webm’.

codecs: str

Codec name, e.g. ‘mp4’, ‘vp9’.

base_url: str

Segment base URL.

class ytpb.representations.VideoRepresentationInfo(itag: str, mime_type: str, codecs: str, base_url: str, width: int, height: int, frame_rate: int)

Bases: RepresentationInfo

Represents attributes of video representations.

width: int

Width of frame.

height: int

Height of frame.

frame_rate: int

Frame per second (FPS).

property quality: VideoQuality

Quality string (resolution and FPS), e.g. ‘720p’, ‘1080p60’.

property fps: int

An alias for frame_rate.

itag: str

itag value, e.g. ‘140’, ‘247’.

mime_type: str

MIME type, e.g. ‘audio/mp4’, ‘video/webm’.

codecs: str

Codec name, e.g. ‘mp4’, ‘vp9’.

base_url: str

Segment base URL.

ytpb.representations.extract_representations(manifest_content: str) list[RepresentationInfo]

Extracts representations from a manifest.

Parameters:

manifest_content – An MPEG-DASH MPD string content.

Returns:

A list of RepresentationInfo objects.