cutcutcodec.core.analysis.video.properties.rate
Find the average frame rate of a video stream.
This information is collected in the metadata of the file. Its access is fast but its value is not always accurate. Especially since the framerate is not always constant within the same stream.
Functions
|
Read in the metadata, the average frequency of the frames. |
Details
- cutcutcodec.core.analysis.video.properties.rate.get_rate_video(filename: Path | str | bytes, index: int = 0, *, backend: str | None = None) Fraction[source]
Read in the metadata, the average frequency of the frames.
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
ffmpegprogram in the background.
- ‘ffmpeg’Uses the modules
‘cv2’ : Uses the module
pip install opencv-contrib-python-headless.
Returns
- fpsFraction
The average frequency of the frames in Hz.
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.rate import get_rate_video >>> from cutcutcodec.utils import get_project_root >>> video = get_project_root() / "media" / "video" / "intro.webm" >>> get_rate_video(video) Fraction(30000, 1001) >>>