cutcutcodec.core.analysis.ffprobe.get_metadata
- cutcutcodec.core.analysis.ffprobe.get_metadata(filename: Path | str | bytes, ignore_errors=False) dict[str][source]
Call
ffprobeand parse the result as a dictionary.Parameters
- filenamepathlike
The pathlike of the file containing streams.
- ignore_errorsboolean, default=False
If True, returns an empty dict rather than throwing an exception if invalid data are detected.
Returns
- metadatadict
All the metadata containing in the container and each streams.
Examples
>>> from pprint import pprint >>> from cutcutcodec.core.analysis.ffprobe import get_metadata >>> from cutcutcodec.utils import get_project_root >>> media = get_project_root().parent / "media" / "video" / "intro.webm" >>> pprint(get_metadata(media)) {'format': {'bit_rate': '401541', 'duration': '9.891000', 'filename': ..., 'format_long_name': 'Matroska / WebM', 'format_name': 'matroska,webm', ... 'size': '496456', 'start_time': '0.000000', 'tags': ..., 'streams': [{'avg_frame_rate': '30000/1001', 'chroma_location': 'left', 'closed_captions': 0, 'codec_long_name': 'Google VP9', 'codec_name': 'vp9', 'codec_tag': '0x0000', 'codec_tag_string': '[0][0][0][0]', 'codec_type': 'video', 'coded_height': 720, 'coded_width': 1280, 'color_primaries': 'bt709', 'color_range': 'tv', 'color_space': 'bt709', 'color_transfer': 'bt709', 'display_aspect_ratio': '16:9', 'disposition': {'attached_pic': 0, ... 'visual_impaired': 0}, 'field_order': 'progressive', 'film_grain': 0, 'has_b_frames': 0, 'height': 720, 'index': 0, 'level': -99, 'pix_fmt': 'yuv420p', 'profile': 'Profile 0', 'r_frame_rate': '30000/1001', 'refs': 1, 'sample_aspect_ratio': '1:1', 'start_pts': 0, 'start_time': '0.000000', 'tags': ..., 'time_base': '1/1000', 'width': 1280}, ... {'avg_frame_rate': '0/0', 'bits_per_sample': 0, 'channel_layout': 'mono', 'channels': 1, 'codec_long_name': 'Vorbis', 'codec_name': 'vorbis', 'codec_tag': '0x0000', 'codec_tag_string': '[0][0][0][0]', 'codec_type': 'audio', 'disposition': {'attached_pic': 0, ... 'visual_impaired': 0}, 'extradata_size': 3340, 'index': 3, 'initial_padding': 0, 'r_frame_rate': '0/0', 'sample_fmt': 'fltp', 'sample_rate': '22050', 'start_pts': 0, 'start_time': '0.000000', 'tags': ..., 'time_base': '1/1000'}]} >>>