Skip to content

Metadata

app.domain.video.metadata

View source code

Video file metadata — dimensions, FPS, frame count, and timing.

See Also

Layer: Domain. Context: Defines application concepts independently of UI and infrastructure implementations.

VideoMetadata dataclass

Static information about a video file (immutable after creation).

ATTRIBUTE DESCRIPTION
_path

File path to the video file.

TYPE: str

_width

Video resolution width in pixels.

TYPE: int

_height

Video resolution height in pixels.

TYPE: int

_fps

Frames per second for playback.

TYPE: float

_frame_count

Total number of frames in the video.

TYPE: int

Note

Extracted once when a video opens, typically from VideoReader. Used to validate frame indices, calculate playback timing, and display resolution, FPS, and frame count in the UI. Immutable after creation.

Example

metadata = VideoMetadata( path="/home/user/video.mp4", width=1920, height=1080, fps=30.0, frame_count=900 # 30 seconds at 30 fps )

interval_ms = metadata.calculate_interval_in_mas() # 33ms (30fps) max_idx = metadata.frame_count - 1 # 899 safe_idx = min(requested_idx, max_idx) # Clamp to valid range

Layer: Domain. Context: Represents application concepts without UI or infrastructure dependencies.

fps: float property

Return the video frame rate.

RETURNS DESCRIPTION
float

Frames per second reported by the video metadata.

frame_count: int property

Return the number of frames reported by the video metadata.

RETURNS DESCRIPTION
int

Total frame count reported by the video metadata.

height: int property

Return the decoded video height in pixels.

RETURNS DESCRIPTION
int

Frame height in pixels.

path: str property

Return the path of the video source.

RETURNS DESCRIPTION
str

Path used to open the video.

width: int property

Return the decoded video width in pixels.

RETURNS DESCRIPTION
int

Frame width in pixels.

__init__(_path: str, _width: int, _height: int, _fps: float, _frame_count: int) -> None

calculate_interval_in_mas() -> int

Calculate the approximate frame interval in milliseconds.

RETURNS DESCRIPTION
int

Frame interval rounded to the nearest millisecond, with a minimum of 1.