Probe#

Local media inspection through ffprobe.

class remote_compression.probe.MediaInfo(width: int, height: int, codec_name: str, subtitles: tuple[SubtitleStream, ...] = (), duration: float | None = None, field_order: str | None = None)[source]#

Result of a successful probe: the first genuine video stream plus subtitles.

width#

Video width in pixels.

Type:

int

height#

Video height in pixels.

Type:

int

codec_name#

ffprobe codec name of the video stream (e.g. h264, hevc).

Type:

str

subtitles#

Subtitle streams, in order of appearance.

Type:

tuple of SubtitleStream

duration#

Container duration in seconds, if known. Used as progress-bar total.

Type:

float, optional

field_order#

ffprobe field order (progressive, tt, bb…) when reported; drives automatic deinterlacing.

Type:

str, optional

class remote_compression.probe.SubtitleStream(index: int, codec_name: str)[source]#

A subtitle stream as reported by ffprobe.

index#

Index of the stream among subtitle streams (0-based, order of appearance), i.e. the i of ffmpeg specifiers like 0:s:i.

Type:

int

codec_name#

ffprobe codec name (e.g. subrip, mov_text, hdmv_pgs_subtitle).

Type:

str

remote_compression.probe.probe(file)[source]#

Inspect a local media file with ffprobe.

Parameters:

file (Path or str) – File location.

Returns:

Extracted information, or None whenever the file cannot be probed: ffprobe missing, non-zero exit, empty or invalid JSON output, or no genuine video stream (cover art, aka attached_pic, does not count).

Return type:

MediaInfo or None

Notes

The command is passed as an argument list (never through a shell), so this works identically on Windows and POSIX.

Width and height are display dimensions: when the stream carries a display-matrix rotation of +/-90 degrees (phone videos), the coded dimensions are swapped accordingly.