pynaviz.audiovideo.AudioHandler.get#

AudioHandler.get(start, end)[source]#

Extract decoded frames from a video between two timestamps.

This method decodes and returns the raw video frames corresponding to the time interval [start, end] in seconds. Decoding begins from the nearest keyframe at or before start, and proceeds sequentially until the end timestamp is reached or exceeded. If the last decoded frame extends beyond end, trailing samples are truncated so that the returned array aligns with the requested time range.

Parameters:
  • start (float) – Start time of the segment to extract, in seconds.

  • end (float) – End time of the segment to extract, in seconds. Must be greater than start.

Returns:

A 2D NumPy array containing the decoded frames for the requested interval. The exact shape depends on the video format and frame size, with the first dimension corresponding to time (frame index or samples) and the remaining dimensions containing audio channels.

Return type:

numpy.typing.NDArray

Notes

  • The returned frames are decoded in sequence and concatenated before being transposed so that time is the first dimension.

  • If end falls between two frames, the last frame is partially trimmed to match the requested duration.

See also

av.AudioFrame <https://pyav.org/docs/stable/api/audio.html#module-av.audio.frame>

The PyAV frame object.