cutcutcodec.core.analysis.video.properties.codec

Find the codec name of a video stream.

Functions

get_codec_video(filename[, index, backend])

Recovers the codec name of a video stream.

Details

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

Recovers the codec name of a video stream.

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 video stream encountered is selected.

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

  • ‘ffmpeg’ : Uses the ffmpeg program in the background.

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

Returns

namestr

The little codec name of the considered 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.codec import get_codec_video
>>> from cutcutcodec.utils import get_project_root
>>> video = get_project_root() / "media" / "video" / "intro.webm"
>>> get_codec_video(video)
'vp9'
>>>