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().parent / "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', ..., '0.000000', '311', '0'], ['video', '33', '0.033000', ..., '0.033000', '48', '0'], ['video', '67', '0.067000', ..., '0.067000', '48', '0'], ..., ['video', '9710', '9.710000', ..., '9.710000', '167', '0'], ['video', '9743', '9.743000', ..., '9.743000', '133', '0'], ['video', '9776', '9.776000', ..., '9.776000', '82', '0']], dtype='<U8'), ... array([['audio', '0', '0.000000', ..., '0.000000', '1', '3'], ['audio', '23', '0.023000', ..., '0.023000', '1', '3'], ['audio', '46', '0.046000', ..., '0.046000', '1', '3'], ..., ['audio', '9822', '9.822000', ..., '9.822000', '100', '3'], ['audio', '9845', '9.845000', ..., '9.845000', '92', '3'], ['audio', '9868', '9.868000', ..., '9.868000', '46', '3']], dtype='<U8')] >>>