cutcutcodec.core.analysis.ffprobe.get_slices_metadata

cutcutcodec.core.analysis.ffprobe.get_slices_metadata(filename: str | bytes | Path, 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
>>> headers, data = (
...     get_slices_metadata("cutcutcodec/examples/audio_5.1_narration.oga", slice_type="packet")
... )
>>> pprint(headers)  
[['codec_type',
  ...
  'stream_index']]
>>> pprint(data)  
[array([['audio', ..., '0'],
       ['audio', ..., '0'],
       ... dtype='<U15')]
>>> headers, data = get_slices_metadata("cutcutcodec/examples/video.mp4", slice_type="packet")
>>> pprint(headers)
[['codec_type',
  'dts',
  'dts_time',
  'duration',
  'duration_time',
  'flags',
  'pos',
  'pts',
  'pts_time',
  'size',
  'stream_index']]
>>> pprint(data)
[array([['video', '-1024', '-0.080000', ..., '0.000000', '5156', '0'],
       ['video', '-512', '-0.040000', ..., '0.240000', '845', '0'],
       ['video', '0', '0.000000', ..., '0.120000', '372', '0'],
       ...,
       ['video', '202240', '15.800000', ..., '15.960000', '354', '0'],
       ['video', '202752', '15.840000', ..., '15.920000', '247', '0'],
       ['video', '203264', '15.880000', ..., '15.880000', '192', '0']],
      shape=(400, 11), dtype='<U9')]
>>>