Skip to content

RoundingMethod

Bases: Enum

Method used to adjust presentation timestamps (PTS).

Source code in video_timestamps/rounding_method.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class RoundingMethod(Enum):
    """Method used to adjust presentation timestamps (PTS).
    """
    FLOOR = auto()
    """Floor"""

    ROUND = auto()
    """Round half up"""

    def __call__(self, number: Fraction) -> int:
        if self.value == self.FLOOR.value:
            method = floor_method
        elif self.value == self.ROUND.value:
            method = round_method
        else:
            raise NotImplementedError(f"Rounding method {self} is not implemented.")
        return method(number)

FLOOR = auto() class-attribute instance-attribute

Floor

ROUND = auto() class-attribute instance-attribute

Round half up