Video Processing
This module provides utilities for post-processing and extracting data from saved ThorVision video files.
pythorvision.video
FrameMetadata
dataclass
Schema for per-frame metadata in a ThorVision video.
This dataclass defines the field names and types for frame metadata. It is used to generate a matching NumPy dtype, enabling efficient storage and vectorized operations when handling large numbers of frames.
Attributes:
| Name | Type | Description |
|---|---|---|
frame_pts |
int64
|
The presentation timestamp (PTS) of the frame from the video container. |
gstreamer_pts |
uint64
|
The GStreamer timestamp when the frame was produced on the server. |
xdaq_timestamp |
uint64
|
The timestamp from the XDAQ system. |
sample_index |
uint32
|
The sample index from the rhythm system. |
ttl_in |
uint32
|
The state of the TTL input lines. |
ttl_out |
uint32
|
The state of the TTL output lines. |
to_numpy_dtype
classmethod
Generates a NumPy dtype from the dataclass fields.
extract_metadata
Extracts per-frame metadata from a ThorVision video.
Opens the video, parses embedded metadata, and returns it as a structured NumPy array using the dtype generated from FrameMetadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
str
|
Path to the video file (e.g., .mkv). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Structured array of frame metadata. Empty array if no metadata is found. |
Raises:
| Type | Description |
|---|---|
AVError
|
If there is an error opening or processing the video file. |