cutcutcodec.core.analysis.ffprobe.get_slices_metadata
- cutcutcodec.core.analysis.ffprobe.get_slices_metadata(filename: Path | str | bytes, slice_type: str = 'frame') tuple[list[list[str]], list[ndarray]][source]
Get the packets informations for all streams.
Parameters
- filenamepathlike
The pathlike of the file containing streams.
- slice_typestr
The type of slices to decode, ‘frame’ or ‘packet’. ‘frame’ is slower but more accurate and informative. ‘packet’ is faster but less acurate.
Returns
- headerslist[list[str]]
For each stream, the name of the columns.
- infos: list[np.ndarray]
For each stream, the 2d str array. Each row correspond to one packet.
Examples
>>> from pprint import pprint >>> from cutcutcodec.core.analysis.ffprobe import get_slices_metadata >>> from cutcutcodec.utils import get_project_root >>> media = get_project_root() / "media" / "video" / "intro.webm" >>> headers, data = get_slices_metadata(media, slice_type="packet") >>> pprint(headers) [['codec_type', 'dts', 'dts_time', 'duration', 'duration_time', 'flags', 'pos', 'pts', 'pts_time', 'size', 'stream_index'], ... ['codec_type', 'dts', 'dts_time', 'duration', 'duration_time', 'flags', 'pos', 'pts', 'pts_time', 'size', 'stream_index']] >>> pprint(data) [array([['video', '0', '0.000000 s', ..., '0.000000 s', '311 byte', '0'], ['video', '33', '0.033000 s', ..., '0.033000 s', '48 byte', '0'], ['video', '67', '0.067000 s', ..., '0.067000 s', '48 byte', '0'], ..., ['video', '9710', '9.710000 s', ..., '9.710000 s', '167 byte', '0'], ['video', '9743', '9.743000 s', ..., '9.743000 s', '133 byte', '0'], ['video', '9776', '9.776000 s', ..., '9.776000 s', '82 byte', '0']], shape=(294, 11), dtype='<U10'), ... array([['audio', '0', '0.000000 s', ..., '0.000000 s', '1 byte', '3'], ['audio', '23', '0.023000 s', ..., '0.023000 s', '1 byte', '3'], ['audio', '46', '0.046000 s', ..., '0.046000 s', '1 byte', '3'], ..., ['audio', '9822', '9.822000 s', ..., '9.822000 s', '100 byte', '3'], ['audio', '9845', '9.845000 s', ..., '9.845000 s', '92 byte', '3'], ['audio', '9868', '9.868000 s', ..., '9.868000 s', '46 byte', '3']], shape=(426, 11), dtype='<U10')] >>>