keyframeinfo.py 800 Bytes
Newer Older
maming's avatar
maming committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright (c) 2025, NVIDIA CORPORATION.
# SPDX-License-Identifier: BSD-3-Clause
from dataclasses import dataclass


@dataclass
class KeyframeInfo:
    """
    Information about a detected keyframe

    The exact meaning of the information will vary per container, however in general

    index: the unit of representation for a frame (e.g., frame number)
    pts: a timestamp that can be used by a decoder to seek to exactly this frame

    """

    index: int
    pts: int

    def __eq__(self, other) -> bool:
        if isinstance(other, KeyframeInfo):
            return self.index == other.index

        return self.index == other

    def __lt__(self, other) -> bool:
        if isinstance(other, KeyframeInfo):
            return self.index < other.index

        return self.index < other