annie.media.probe

Cheap media probing via ffprobe (service).

Browse shows video / audio tags per sample. Whether a file has frames is known from the scan (a video file is present); whether it has an audio stream is not, so it is probed on demand with ffprobe — much cheaper than decoding. The command builder is pure and unit-tested; the thin runner spawns it.

Functions

audio_probe_command(→ list[str])

Build the ffprobe argv that lists a file's audio streams.

video_probe_command(→ list[str])

Build the ffprobe argv that lists a file's video streams.

has_audio(→ bool)

Return whether path has at least one audio stream.

has_video(→ bool)

Return whether path has at least one video stream.

Module Contents

annie.media.probe.audio_probe_command(path: str | pathlib.Path) → list[str][source]

Build the ffprobe argv that lists a file’s audio streams.

Parameters:

path – The media file to inspect.

Returns:

The ffprobe argv (no shell). Non-empty stdout means an audio stream exists.

annie.media.probe.video_probe_command(path: str | pathlib.Path) → list[str][source]

Build the ffprobe argv that lists a file’s video streams.

Parameters:

path – The media file to inspect.

Returns:

The ffprobe argv (no shell). Empty stdout means the file has no video stream (e.g. an .mp4 that is really audio-only and yields no frames).

annie.media.probe.has_audio(path: str | pathlib.Path) → bool[source]

Return whether path has at least one audio stream.

Parameters:

path – The media file to inspect.

Returns:

True if ffprobe reports an audio stream, False otherwise (including on any ffprobe error, so a missing ffprobe degrades to “no audio”).

annie.media.probe.has_video(path: str | pathlib.Path) → bool[source]

Return whether path has at least one video stream.

Parameters:

path – The media file to inspect.

Returns:

True if ffprobe reports a video stream, False otherwise.