cutcutcodec.core.analysis.video.properties.resolution.get_resolution

cutcutcodec.core.analysis.video.properties.resolution.get_resolution(filename: Path | str | bytes, index: int = 0, *, backend: str | None = None) tuple[int, int][source]

Read in the metadata, the display video resolution.

Parameters

filenamepathlike

The pathlike of the file containing a video stream.

indexint

The relative index of the video stream being considered, by default the first stream encountered is selected.

backendstr, optional
  • None (default) : Try to read the stream by trying differents backends.

  • ‘ffmpeg’Uses the modules pip install ffmpeg-python

    which are using the ffmpeg program in the background.

  • ‘cv2’ : Uses the module pip install opencv-contrib-python-headless.

Returns

height, widthint

The number of diplay pixel of the frames of the video stream.

Raises

MissingStreamError

If the file does not contain a playable video stream.

MissingInformation

If the information is unavailable.

Examples

>>> from cutcutcodec.core.analysis.video.properties.resolution import get_resolution
>>> from cutcutcodec.utils import get_project_root
>>> media = get_project_root() / "media" / "video" / "intro.webm"
>>> get_resolution(media)
(720, 1280)
>>>